Commit ba3f6556 by Tuomas Riihimäki

Code cleanup

1 parent 8ba089a6
Showing with 178 additions and 315 deletions
......@@ -130,7 +130,7 @@ public abstract class GenericFacade<C extends ModelInterface> {
}
protected SearchResult<C> searcher(SearchQuery search, FacadeCallback<C> cb1, FacadeCallback<C> cb2) {
ArrayList<FacadeCallback<C>> cbs = new ArrayList<FacadeCallback<C>>();
ArrayList<FacadeCallback<C>> cbs = new ArrayList<>();
cbs.add(cb1);
cbs.add(cb2);
return searcher(search, cbs);
......@@ -138,7 +138,7 @@ public abstract class GenericFacade<C extends ModelInterface> {
}
protected SearchResult<C> searcher(SearchQuery search, FacadeCallback<C> cb1, FacadeCallback<C> cb2, FacadeCallback<C> cb3) {
ArrayList<FacadeCallback<C>> cbs = new ArrayList<FacadeCallback<C>>();
ArrayList<FacadeCallback<C>> cbs = new ArrayList<>();
cbs.add(cb1);
cbs.add(cb2);
cbs.add(cb3);
......@@ -147,7 +147,7 @@ public abstract class GenericFacade<C extends ModelInterface> {
}
protected SearchResult<C> searcher(SearchQuery search, FacadeCallback<C> cb1, FacadeCallback<C> cb2, FacadeCallback<C> cb3, FacadeCallback<C> cb4) {
ArrayList<FacadeCallback<C>> cbs = new ArrayList<FacadeCallback<C>>();
ArrayList<FacadeCallback<C>> cbs = new ArrayList<>();
cbs.add(cb1);
cbs.add(cb2);
cbs.add(cb3);
......@@ -174,7 +174,7 @@ public abstract class GenericFacade<C extends ModelInterface> {
listQ.setMaxResults(search.getPagesize());
}
return new SearchResult<C>(listQ.getResultList(), countQ.getSingleResult());
return new SearchResult<>(listQ.getResultList(), countQ.getSingleResult());
}
protected From<?, C> searchCallbacks(CriteriaQuery<?> cq, List<FacadeCallback<C>> list, boolean isFullQuery) {
......@@ -185,7 +185,7 @@ public abstract class GenericFacade<C extends ModelInterface> {
Root<T> root = cq.from(clazz);
ArrayList<Predicate> predicates = handlePredicates(cq, list, root, isFullQuery);
if (!predicates.isEmpty()) {
Predicate[] preds = predicates.toArray(new Predicate[predicates.size()]);
Predicate[] preds = predicates.toArray(new Predicate[0]);
cq.where(preds);
}
......@@ -197,7 +197,7 @@ public abstract class GenericFacade<C extends ModelInterface> {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
ArrayList<Predicate> predicates = new ArrayList<Predicate>();
ArrayList<Predicate> predicates = new ArrayList<>();
for (FacadeCallback<T> fc : list) {
if (fc != null) {
fc.exec(cb, cq, root, predicates, isFullQuery);
......
......@@ -28,7 +28,7 @@ import javax.faces.convert.Converter;
* Use this converter if you want to do some database find -magic via string
* @param <T>
*/
public abstract class GenericEntityFinderConverter<T extends ModelInterface> implements Converter {
public abstract class GenericEntityFinderConverter<T extends ModelInterface> implements Converter<T> {
protected abstract T find(Integer id);
protected abstract T find(String searchString);
......@@ -38,7 +38,7 @@ public abstract class GenericEntityFinderConverter<T extends ModelInterface> imp
}
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
public T getAsObject(FacesContext context, UIComponent component, String value) {
T ret = null;
Integer id = null;
if (value != null) {
......@@ -56,11 +56,10 @@ public abstract class GenericEntityFinderConverter<T extends ModelInterface> imp
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
public String getAsString(FacesContext context, UIComponent component, T entity) {
String ret = "0";
if (value != null && value instanceof ModelInterface) {
ModelInterface entity = (ModelInterface) value;
if (entity != null) {
if (entity.getId() != null) {
ret = entity.getId().toString();
}
......
......@@ -24,7 +24,7 @@ import javax.faces.convert.Converter;
import fi.codecrew.moya.utilities.jpa.ModelInterface;
public abstract class GenericIntegerEntityConverter<T extends ModelInterface> implements Converter {
public abstract class GenericIntegerEntityConverter<T extends ModelInterface> implements Converter<T> {
protected abstract T find(Integer id);
......@@ -33,7 +33,7 @@ public abstract class GenericIntegerEntityConverter<T extends ModelInterface> im
}
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
public T getAsObject(FacesContext context, UIComponent component, String value) {
T ret = null;
Integer id = null;
if (value != null) {
......@@ -46,11 +46,10 @@ public abstract class GenericIntegerEntityConverter<T extends ModelInterface> im
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
public String getAsString(FacesContext context, UIComponent component, T entity) {
String ret = "0";
if (value != null && value instanceof ModelInterface) {
ModelInterface entity = (ModelInterface) value;
if (entity != null) {
if (entity.getId() != null) {
ret = entity.getId().toString();
}
......
......@@ -44,7 +44,7 @@ public class JsonUtilsTest {
@Test
public final void testGetSubObject() {
JsonObject meta = jsonObject("{\"foo\":\"bar\",\"baz\":{\"quuz\":\"plop\"}}");
ArrayList<String> path = new ArrayList<String>();
ArrayList<String> path = new ArrayList<>();
path.add("baz");
JsonValue expected = jsonObject("{\"quuz\":\"plop\"}");
......@@ -57,7 +57,7 @@ public class JsonUtilsTest {
JsonObject meta = jsonObject("{\"foo\":\"bar\"}");
JsonObject newData = jsonObject("{\"quux\":\"plop\"}");
ArrayList<String> path = new ArrayList<String>();
ArrayList<String> path = new ArrayList<>();
path.add("baz");
JsonObject actual = JsonUtils.alterSubObject(meta, path, newData);
......@@ -71,7 +71,7 @@ public class JsonUtilsTest {
JsonObject meta = jsonObject("{\"bystander1\":\"canary1\", \"module1\":{\"bystander2\":\"canary2\",\"submodule1\":{\"replacee1\":\"replacedvalue1\",\"r2\":\"rv2\"}}}");
JsonObject newData = jsonObject("{\"quux\":\"plop\"}");
ArrayList<String> path = new ArrayList<String>();
ArrayList<String> path = new ArrayList<>();
path.add("module1");
path.add("submodule1");
......
......@@ -49,7 +49,7 @@ public class GraphQLBuilder {
public Set<GraphQLType> getTypes() {
Set<GraphQLType> ret = new HashSet<>(enums.values());
List<GraphQLObjectType> retEnt = entities.values().stream().map(v -> v.build()).collect(Collectors.toList());
logger.warn("Returning entities", retEnt);
logger.warn("Returning entities: {}", retEnt);
ret.addAll(retEnt);
logger.warn("Enums {}, entities {}", enums, entities);
logger.warn("Builder returning types: {}", ret);
......@@ -59,7 +59,7 @@ public class GraphQLBuilder {
public GraphQLTypeReference typeFor(String typeName) {
logger.warn("Adding typeFor: {}", typeName);
if (!entities.containsKey(typeName) && !enums.containsKey(typeName)) {
logger.warn("Adding unknown type: this might be an error!" + typeName, new RuntimeException().fillInStackTrace());
logger.warn("Adding unknown type: {} this might be an error!", typeName, new RuntimeException().fillInStackTrace());
uncheckedTypes.add(typeName);
}
......@@ -71,14 +71,14 @@ public class GraphQLBuilder {
}
public <X extends Enum> GraphQLOutputType getEnum(Class<X> type) {
public <X extends Enum<?>> GraphQLOutputType getEnum(Class<X> type) {
String name = type.getSimpleName();
if (name == null) {
throw new NullPointerException("Trying to get enum with type " + type);
}
if (!enums.containsKey(name)) {
GraphQLEnumType.Builder ret = newEnum().name(name);
for (Enum c : type.getEnumConstants()) {
for (Enum<?> c : type.getEnumConstants()) {
ret.value(c.name());
}
enums.put(name, ret.build());
......
......@@ -16,6 +16,6 @@ public class PropertyFetchWrapper<T, INNER> implements DataFetcher<T> {
@Override
public T get(DataFetchingEnvironment environment) {
INNER field = fetcher.get(environment);
return innerFetcher.get(new DataFetchingEnvironmentWrapper(environment, field));
return innerFetcher.get(new DataFetchingEnvironmentWrapper<>(environment, field));
}
}
......@@ -12,5 +12,5 @@ public class ArrayListWrapper<T> {
this.list = list;
}
public ArrayList<T> list = new ArrayList<T>();
public ArrayList<T> list = new ArrayList<>();
}
\ No newline at end of file
......@@ -22,12 +22,7 @@ import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import fi.codecrew.moya.beans.NetworkAssociationBeanLocal;
......
package fi.codecrew.moya.rest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
......@@ -65,7 +66,7 @@ public class PojoUtils {
}
public static CardRoot parsePrintedCards(List<PrintedCard> cards) {
ArrayList<PrintedCardRestPojo> ret = new ArrayList<PrintedCardRestPojo>();
ArrayList<PrintedCardRestPojo> ret = new ArrayList<>();
for (PrintedCard c : cards) {
ret.add(initPrintedCardRestPojo(c));
}
......@@ -125,7 +126,7 @@ public class PojoUtils {
}
private static List<PlacePojo> parsePlaces(List<Place> places) {
ArrayList<PlacePojo> ret = new ArrayList<PlacePojo>();
ArrayList<PlacePojo> ret = new ArrayList<>();
for (Place place : places) {
ret.add(initPlacePojo(place));
}
......@@ -205,7 +206,7 @@ public class PojoUtils {
}
public static List<ProductRestPojo> parseProducts(List<Product> prods) {
ArrayList<ProductRestPojo> ret = new ArrayList<ProductRestPojo>();
ArrayList<ProductRestPojo> ret = new ArrayList<>();
for (Product p : prods) {
ret.add(initProductRestPojo(p));
}
......@@ -217,7 +218,7 @@ public class PojoUtils {
ret.setId(product.getId());
ret.setName(product.getName());
ret.setDescription(product.getDescription());
ret.setPrice(product.getPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
ret.setPrice(product.getPrice().setScale(2, RoundingMode.HALF_UP).toString());
return ret;
......
......@@ -22,15 +22,12 @@ import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource;
import io.swagger.v3.oas.integration.SwaggerConfiguration;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.servers.Server;
import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletConfig;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Context;
import java.util.Arrays;
......
......@@ -2,7 +2,6 @@ package fi.codecrew.moya.rest;
import fi.codecrew.moya.rest.placemap.v1.PlaceCodePojo;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;
......
......@@ -43,7 +43,7 @@ public abstract class AbstractRestViewV1 {
* @return List<String>
*/
public List<String> pathToStrings(List<PathSegment> path) {
ArrayList<String> stringList = new ArrayList<String>(path.size());
ArrayList<String> stringList = new ArrayList<>(path.size());
for (PathSegment s : path) {
String segmentString = s.getPath();
if (segmentString != null && !segmentString.isEmpty()) {
......
package fi.codecrew.moya.rest.placemap.v1;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
......@@ -9,38 +8,17 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.BarcodeBeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.PlaceBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.beans.map.QueueBeanLocal;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.rest.PojoUtils;
import fi.codecrew.moya.rest.pojo.placemap.v1.IntegerRoot;
import fi.codecrew.moya.rest.pojo.placemap.v1.PlacemapMapRootPojo;
import fi.codecrew.moya.rest.pojo.placemap.v1.SimplePlacePojo;
import fi.codecrew.moya.rest.pojo.placemap.v1.SimplePlacelistRoot;
import fi.codecrew.moya.utilities.PasswordFunctions;
import fi.codecrew.moya.web.cdiview.map.MapPlacechangeView;
import fi.codecrew.moya.web.cdiview.map.MapPlacechangeView.MoveContainer;
import fi.codecrew.moya.web.cdiview.user.UserView;
@RequestScoped
@Path("/placemove/v1")
......
package fi.codecrew.moya.rest.v2;
import fi.codecrew.moya.enums.Gender;
import fi.codecrew.moya.model.CardCode;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.User;
import fi.codecrew.moya.rest.pojo.userinfo.v3.CardCodePojoV3;
import fi.codecrew.moya.rest.pojo.userinfo.v3.PrintedCardRestPojoV3;
import fi.codecrew.moya.rest.v2.pojo.UserPojo;
import java.io.Serializable;
import java.util.ArrayList;
/**
* Created by jkj on 2015-05-31.
......
......@@ -2,7 +2,6 @@ package fi.codecrew.moya.rest.v2;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
......
......@@ -3,7 +3,6 @@ package fi.codecrew.moya.rest.v3;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.handler.SessionHandler;
import fi.codecrew.moya.handler.SessionStore;
import fi.codecrew.moya.rest.v3.pojo.LocalePojoV3;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
......
package fi.codecrew.moya.rest.v3.pojo;
import fi.codecrew.moya.model.Vip;
import fi.codecrew.moya.model.VipProduct;
import fi.codecrew.moya.rest.pojo.vip.v2.VipProductPojo;
......
......@@ -69,7 +69,7 @@ public class UserCardPngServlet extends GenericImageServlet {
@Override
protected ImageMover getImagedata(HttpServletRequest request) {
ImageMover ret = new ImageMover();
List<String> urlparts = new ArrayList<String>();
List<String> urlparts = new ArrayList<>();
if (request.getPathInfo() != null)
{
Matcher matcher = URLPATTERN.matcher(request.getPathInfo());
......
......@@ -45,7 +45,6 @@ import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.beans.UserUtilBeanLocal;
import fi.codecrew.moya.enums.apps.EventPermission;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Poll;
import fi.codecrew.moya.model.PollQuestion;
import fi.codecrew.moya.model.PossibleAnswer;
......
......@@ -2,19 +2,14 @@ package fi.codecrew.moya.web.api;
import fi.codecrew.moya.beans.ApiApplicationBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.model.ApiApplication;
import fi.codecrew.moya.model.ApiApplicationInstance;
import fi.codecrew.moya.utilities.PasswordFunctions;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel;
import javax.inject.Named;
import java.util.List;
@Named
@ConversationScoped
......
......@@ -6,17 +6,13 @@ import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import org.primefaces.component.log.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.ApiApplicationBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.api.ApiBeanLocal;
import fi.codecrew.moya.enums.apps.EventPermission;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.model.ApiApplication;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
......
......@@ -84,7 +84,7 @@ public abstract class PaginationView<T extends ModelInterface> extends GenericCD
public ListDataModel<T> getResultdatamodel() {
if (resultdatamodel == null) {
resultdatamodel = new ListDataModel<T>(results);
resultdatamodel = new ListDataModel<>(results);
}
return resultdatamodel;
}
......
......@@ -64,7 +64,7 @@ public class CardMassPrintView extends GenericCDIView implements Serializable {
public void initView() {
List<EventUser> eventUsers = userCartView.getUsercart();
ArrayList<Integer> userIdList = new ArrayList<Integer>();
ArrayList<Integer> userIdList = new ArrayList<>();
for (EventUser eu : eventUsers) {
userIdList.add(eu.getId());
}
......@@ -95,7 +95,7 @@ public class CardMassPrintView extends GenericCDIView implements Serializable {
cardPrintBean.acceptMassPrintResult(mpr);
}
userCartView.setUsercart(new ArrayList<EventUser>());
userCartView.setUsercart(new ArrayList<>());
return "accepted";
}
......
......@@ -294,19 +294,19 @@ public class CardTemplateDataEditView extends GenericCDIView {
}
public List<CardObjectDataType> getCardObjectDataTypes() {
return new ArrayList<CardObjectDataType>(Arrays.asList(CardObjectDataType.values()));
return new ArrayList<>(Arrays.asList(CardObjectDataType.values()));
}
public List<CardTextDataType> getCardTextDataTypes() {
List<CardTextDataType> types = new ArrayList<CardTextDataType>(Arrays.asList(CardTextDataType.values()));
List<CardTextDataType> types = new ArrayList<>(Arrays.asList(CardTextDataType.values()));
return types;
}
public List<CardTextStyle> getFontStyles() {
return new ArrayList<CardTextStyle>(Arrays.asList(CardTextStyle.values()));
return new ArrayList<>(Arrays.asList(CardTextStyle.values()));
}
public List<CardTextAlignment> getTextAlignments() {
return new ArrayList<CardTextAlignment>(Arrays.asList(CardTextAlignment.values()));
return new ArrayList<>(Arrays.asList(CardTextAlignment.values()));
}
}
......@@ -65,7 +65,7 @@ public class SitePageView extends GenericCDIView {
{
sitepage = new SitePage();
sitepage.setName(managedPage);
sitepage.setContents(new ArrayList<PageContent>());
sitepage.setContents(new ArrayList<>());
sitepage.getContents().add(new PageContent(sitepage));
}
super.beginConversation();
......
......@@ -92,7 +92,7 @@ public class EticketView extends GenericCDIView {
}
public ListDataModel<GroupMembership> getGroupMemberships() {
memberlist = new ListDataModel<GroupMembership>(ticketBean.findMembershipPrintlistForUser(userView.getSelectedUser()));
memberlist = new ListDataModel<>(ticketBean.findMembershipPrintlistForUser(userView.getSelectedUser()));
return memberlist;
}
......
......@@ -88,7 +88,7 @@ public class StandaloneEticketView extends GenericCDIView {
public ListDataModel<GroupMembership> getGroupMemberships() {
memberlist = new ListDataModel<GroupMembership>(ticketBean.findMembershipPrintlistForUser(user));
memberlist = new ListDataModel<>(ticketBean.findMembershipPrintlistForUser(user));
return memberlist;
}
......
......@@ -68,7 +68,7 @@ public class LicenseView extends GenericCDIView {
if (licenses == null) {
this.currentLicense = new LicenseTarget();
this.currentLicense.setEvent(eventBean.getCurrentEvent());
this.licenses = new ListDataModel<LicenseTarget>(licenseBean.findAll(eventBean.getCurrentEvent()));
this.licenses = new ListDataModel<>(licenseBean.findAll(eventBean.getCurrentEvent()));
this.beginConversation();
}
}
......@@ -78,8 +78,8 @@ public class LicenseView extends GenericCDIView {
if (super.requirePermissions(LicensePermission.VIEW_OWN_CODES)) {
if (licenseCodes == null) {
currentUser = permissionBean.getCurrentUser();
this.licenseCodes = new ListDataModel<LicenseCode>(currentUser.getUser().getLicenseCodes());
this.licenses = new ListDataModel<LicenseTarget>(licenseBean.findUnopenedUserGames(currentUser));
this.licenseCodes = new ListDataModel<>(currentUser.getUser().getLicenseCodes());
this.licenses = new ListDataModel<>(licenseBean.findUnopenedUserGames(currentUser));
this.beginConversation();
}
}
......@@ -87,7 +87,7 @@ public class LicenseView extends GenericCDIView {
public String saveCurrentLicense() {
licenseBean.saveOrCreateLicense(currentLicense);
this.licenses = new ListDataModel<LicenseTarget>(licenseBean.findAll(eventBean.getCurrentEvent()));
this.licenses = new ListDataModel<>(licenseBean.findAll(eventBean.getCurrentEvent()));
return null;
}
......
......@@ -31,7 +31,7 @@ public class AjaxMapManageView extends GenericCDIView {
public void placeClicked(ActionEvent event) {
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
String placeIdStr = ec.getRequestParameterMap().get("mgmtPlaceId");
logger.info("Place id {}, str", placeId, placeIdStr);
logger.info("Place id {}, str {}", placeId, placeIdStr);
placeId = Integer.parseInt(placeIdStr);
place = placebean.find(placeId);
......
package fi.codecrew.moya.web.cdiview.map;
import java.awt.*;
import java.io.Serializable;
import java.util.*;
import java.util.List;
......
......@@ -89,7 +89,7 @@ public class PlacegroupView extends GenericCDIView {
public String editGroup() {
setGroup(placegroups.getRowData());
setPlacelist(new ListDataModel<Place>(group.getPlaces()));
setPlacelist(new ListDataModel<>(group.getPlaces()));
return "/place/editGroup";
}
......@@ -197,7 +197,7 @@ public class PlacegroupView extends GenericCDIView {
}
public ListDataModel<GroupMembership> getGroupMemberships() {
memberlist = new ListDataModel<GroupMembership>(placegroupBean.getMembershipsAndCreations(user));
memberlist = new ListDataModel<>(placegroupBean.getMembershipsAndCreations(user));
return memberlist;
}
......@@ -251,8 +251,7 @@ public class PlacegroupView extends GenericCDIView {
public ListDataModel<PlaceGroup> getPlacegroups() {
if (placegroups == null) {
List<PlaceGroup> retlist = new ArrayList<PlaceGroup>();
retlist.addAll(placegroupBean.getPlacegroups(user));
List<PlaceGroup> retlist = new ArrayList<>(placegroupBean.getPlacegroups(user));
for (GroupMembership gm : placegroupBean.getMemberships(user)) {
if (!retlist.contains(gm.getPlaceGroup())) {
......@@ -260,7 +259,7 @@ public class PlacegroupView extends GenericCDIView {
}
}
placegroups = new ListDataModel<PlaceGroup>(retlist);
placegroups = new ListDataModel<>(retlist);
}
return placegroups;
}
......
......@@ -24,7 +24,6 @@ import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import org.joda.time.format.ISODateTimeFormat;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
......
......@@ -76,7 +76,7 @@ public class UnlockedPlaceView extends GenericCDIView {
public void init()
{
if (places == null) {
HashMap<EventUser, UnlockedPlaceContainer> usermap = new HashMap<EventUser, UnlockedPlaceContainer>();
HashMap<EventUser, UnlockedPlaceContainer> usermap = new HashMap<>();
EventMap map = null;
if (getMapId() != null) {
......
......@@ -65,7 +65,7 @@ public class MenuView implements Serializable{
private HashSet<MenuNavigation> navis;
private Map<String, List<PageContent>> contents = new HashMap<String, List<PageContent>>();
private Map<String, List<PageContent>> contents = new HashMap<>();
@EJB
private SitePageBeanLocal pagebean;
......@@ -125,7 +125,7 @@ public class MenuView implements Serializable{
public List<JsfMenuitem> getViewChangeTopmenu()
{
if (viewchangeTopmenu == null) {
viewchangeTopmenu = new ArrayList<JsfMenuitem>();
viewchangeTopmenu = new ArrayList<>();
for (MenuNavigation topmenu : menubean.getTopmenus()) {
......@@ -155,8 +155,8 @@ public class MenuView implements Serializable{
{
if (menus == null)
{
menus = new LinkedList<List<JsfMenuitem>>();
navis = new HashSet<MenuNavigation>();
menus = new LinkedList<>();
navis = new HashSet<>();
MenuNavigation pathIter = menubean.findNavigation(layoutview.getPagepath());
while (pathIter != null) {
......@@ -172,7 +172,7 @@ public class MenuView implements Serializable{
}
private LinkedList<JsfMenuitem> addMenu(List<MenuNavigation> children) {
LinkedList<JsfMenuitem> ret = new LinkedList<JsfMenuitem>();
LinkedList<JsfMenuitem> ret = new LinkedList<>();
// Iterate through children
for (MenuNavigation child : children) {
// if is visible, permission is null or has permission, continue
......
......@@ -256,7 +256,7 @@ public class EventOrgView extends GenericCDIView {
public void setEvent(LanEvent event) {
this.event = event;
eventdomains = new ListDataModel<LanEventDomain>(event.getDomains());
eventdomains = new ListDataModel<>(event.getDomains());
}
public ListDataModel<LanEventDomain> getEventdomains() {
......@@ -317,7 +317,7 @@ public class EventOrgView extends GenericCDIView {
public List<User> getSuperUsers() {
if (!permbean.getCurrentUser().isSuperadmin())
return new ArrayList<User>();
return new ArrayList<>();
return userBean.findSuperusers();
}
......
......@@ -18,7 +18,6 @@
*/
package fi.codecrew.moya.web.cdiview.organisation;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -66,7 +65,7 @@ public class EventPropertyView extends GenericCDIView {
private LanEventPrivateProperty privateProperty;
public List<LanEventPropertyKey> getAvailablePropertyKeys() {
List<LanEventPropertyKey> ret = new ArrayList<LanEventPropertyKey>(Arrays.asList(LanEventPropertyKey.values()));
List<LanEventPropertyKey> ret = new ArrayList<>(Arrays.asList(LanEventPropertyKey.values()));
if (createKey != null) {
ret.remove(createKey);
}
......@@ -81,7 +80,7 @@ public class EventPropertyView extends GenericCDIView {
public List<LanEventPrivatePropertyKey> getAvailablePrivatePropertyKeys() {
List<LanEventPrivatePropertyKey> ret = null;
if (isPrivatePropertyPermission() && eventbean.getCurrentEvent().equals(eventorgview.getEvent())) {
ret = new ArrayList<LanEventPrivatePropertyKey>(Arrays.asList(LanEventPrivatePropertyKey.values()));
ret = new ArrayList<>(Arrays.asList(LanEventPrivatePropertyKey.values()));
if (createPrivateKey != null) {
ret.remove(createPrivateKey);
}
......@@ -220,14 +219,14 @@ public class EventPropertyView extends GenericCDIView {
public ListDataModel<LanEventProperty> getProperties() {
if (properties == null && eventorgview != null && eventorgview.getEvent() != null) {
properties = new ListDataModel<LanEventProperty>(eventorgview.getEvent().getProperties());
properties = new ListDataModel<>(eventorgview.getEvent().getProperties());
}
return properties;
}
public ListDataModel<LanEventPrivateProperty> getPrivateProperties() {
if (privateProperties == null && eventorgview != null && eventbean.getCurrentEvent().equals(eventorgview.getEvent())) {
privateProperties = new ListDataModel<LanEventPrivateProperty>(eventbean.getPrivateProperties());
privateProperties = new ListDataModel<>(eventbean.getPrivateProperties());
}
return privateProperties;
}
......
......@@ -102,13 +102,13 @@ public class PollView extends GenericCDIView {
return;
}
logger.debug("initializing poll questions {}", poll.getQuestions());
pages = new HashMap<Integer, List<QuestionWrapper>>();
pages = new HashMap<>();
for (PollQuestion q : poll.getQuestions()) {
if (!getPages().containsKey(q.getPage())) {
getPages().put(q.getPage(), new LinkedList<QuestionWrapper>());
getPages().put(q.getPage(), new LinkedList<>());
}
getPages().get(q.getPage()).add(new QuestionWrapper(q));
}
......@@ -134,7 +134,7 @@ public class PollView extends GenericCDIView {
}
private List<PollAnswer> createAnswers() {
ArrayList<PollAnswer> ret = new ArrayList<PollAnswer>();
ArrayList<PollAnswer> ret = new ArrayList<>();
for (List<QuestionWrapper> qw : getPages().values()) {
for (QuestionWrapper wrapper : qw) {
ret.addAll(wrapper.getAnswers());
......@@ -200,7 +200,7 @@ public class PollView extends GenericCDIView {
public QuestionWrapper(PollQuestion q) {
question = q;
answers = new ArrayList<PollAnswer>();
answers = new ArrayList<>();
for (PossibleAnswer possible : q.getAnswers()) {
answers.add(new PollAnswer(possible));
}
......
......@@ -61,7 +61,7 @@ public class ReaderListDataView extends GenericCDIView {
public ListDataModel<Reader> getReaders()
{
if (readers == null) {
readers = new ListDataModel<Reader>(readerbean.getReaders());
readers = new ListDataModel<>(readerbean.getReaders());
}
return readers;
}
......@@ -82,7 +82,7 @@ public class ReaderListDataView extends GenericCDIView {
public ListDataModel<Reader> getSelectedReaders() {
ArrayList<Reader> readers = new ArrayList<Reader>();
ArrayList<Reader> readers = new ArrayList<>();
for(Integer rid : readerNameContainer.getReaders()) {
Reader r = readerbean.getReader(rid);
......@@ -91,7 +91,7 @@ public class ReaderListDataView extends GenericCDIView {
readers.add(r);
}
return new ListDataModel<Reader>(readers);
return new ListDataModel<>(readers);
}
}
......
......@@ -37,7 +37,7 @@ public class ReaderNameContainer implements Serializable {
//private Integer readerId;
// handling first user when using via getReaderId and setReaderId;
private final List<Integer> readers = new ArrayList<Integer>();;
private final List<Integer> readers = new ArrayList<>();;
private boolean autopoll = false;
......
......@@ -27,6 +27,7 @@ import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import fi.codecrew.moya.model.role.Role;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -40,7 +41,6 @@ import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.Reader;
import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.model.ReaderType;
import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.shop.UserCardWrapper;
import fi.codecrew.moya.web.cdiview.user.UserView;
......@@ -163,7 +163,7 @@ public class ReaderView extends GenericCDIView {
public List<Product> getAutoProducts() {
List<Product> ret = new ArrayList<Product>();
List<Product> ret = new ArrayList<>();
ret.add(Product.EMPTY_PRODUCT);
ret.addAll(shopBean.getProducts());
return ret;
......@@ -177,7 +177,7 @@ public class ReaderView extends GenericCDIView {
public ListDataModel<ReaderEvent> getReaderEvents()
{
readerEventList = new ListDataModel<ReaderEvent>(readerbean.getReaderEvents(namecontainer.getReaderId()));
readerEventList = new ListDataModel<>(readerbean.getReaderEvents(namecontainer.getReaderId()));
return readerEventList;
}
......
......@@ -28,7 +28,6 @@ import javax.inject.Named;
import fi.codecrew.moya.beans.CheckoutFiV2BeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.checkout.CheckoutCreateResponsePojo;
import fi.codecrew.moya.model.LanEventProperty;
import fi.codecrew.moya.model.LanEventPropertyKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
......@@ -131,7 +131,7 @@ public class BillListView extends GenericCDIView {
public void initSummaryView()
{
if (super.requirePermissions(BillPermission.READ_ALL)) {
setBillsummary(new ArrayList<BillSummary>(billbean.getBillLineSummary()));
setBillsummary(new ArrayList<>(billbean.getBillLineSummary()));
}
}
......
......@@ -18,15 +18,12 @@
*/
package fi.codecrew.moya.web.cdiview.shop;
import fi.codecrew.moya.beans.CheckoutFiBeanLocal;
import fi.codecrew.moya.beans.CheckoutFiV2BeanLocal;
import fi.codecrew.moya.util.CheckoutReturnType;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Named;
import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
......
......@@ -66,7 +66,7 @@ public class DiscountView extends GenericCDIView {
public String create() {
if (product.getDiscounts() == null) {
product.setDiscounts(new ArrayList<Discount>());
product.setDiscounts(new ArrayList<>());
}
product.getDiscounts().add(discount);
......
......@@ -90,7 +90,7 @@ public class FoodWaveFoodView extends GenericCDIView {
foodWave = foodWaveBean.findFoodwave(getFoodwaveid());
logger.debug("Foodwave {}", foodWave);
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productGTList(foodWave.getTemplate().getProducts(), userview.getSelectedUser()));
shoppingcart = new ListDataModel<>(ProductShopItem.productGTList(foodWave.getTemplate().getProducts(), userview.getSelectedUser()));
this.beginConversation();
}
......@@ -232,9 +232,8 @@ public class FoodWaveFoodView extends GenericCDIView {
}
private boolean productsInCart() {
Iterator<ProductShopItem> nullcheckIter = getShoppingcart().iterator();
while (nullcheckIter.hasNext()) {
if (nullcheckIter.next().getCount().compareTo(BigDecimal.ZERO) > 0) {
for (ProductShopItem productShopItem : getShoppingcart()) {
if (productShopItem.getCount().compareTo(BigDecimal.ZERO) > 0) {
return true;
}
}
......
......@@ -108,7 +108,7 @@ public class FoodWaveView extends GenericCDIView {
}
}
foodWaves = new ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves());
foodWaves = new ListDataModel<>(foodWaveBean.getEventFoodWaves());
}
public String createFoodwave() {
......@@ -132,9 +132,9 @@ public class FoodWaveView extends GenericCDIView {
if (templateId != null)
{
template = foodWaveBean.findTemplate(templateId);
foodWaves = new ListDataModel<FoodWave>(template.getFoodwaves());
foodWaves = new ListDataModel<>(template.getFoodwaves());
} else {
foodWaves = new ListDataModel<FoodWave>(foodWaveBean.getOpenFoodWaves());
foodWaves = new ListDataModel<>(foodWaveBean.getOpenFoodWaves());
}
super.beginConversation();
}
......@@ -160,7 +160,7 @@ public class FoodWaveView extends GenericCDIView {
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && template == null)
{
template = new FoodWaveTemplate();
template.setProducts(new ArrayList<Product>());
template.setProducts(new ArrayList<>());
template.setEvent(eventbean.getCurrentEvent());
createNewProductSkeleton();
......@@ -172,7 +172,7 @@ public class FoodWaveView extends GenericCDIView {
public List<FoodwaveProductSummary> getProductSummaries() {
HashMap<Product, FoodwaveProductSummary> pmap = new HashMap<Product, FoodwaveProductSummary>();
HashMap<Product, FoodwaveProductSummary> pmap = new HashMap<>();
for (AccountEvent ae : getSelectedFoodWave().getAccountEvents()) {
if (!pmap.containsKey(ae.getProduct())) {
......@@ -183,11 +183,11 @@ public class FoodWaveView extends GenericCDIView {
pmap.get(ae.getProduct()).add(ae);
}
System.out.println("::" + pmap.values().size());
return new ArrayList<FoodwaveProductSummary>(pmap.values());
return new ArrayList<>(pmap.values());
}
private void createNewProductSkeleton() {
TreeSet<ProductFlag> ts = new TreeSet<ProductFlag>();
TreeSet<ProductFlag> ts = new TreeSet<>();
currentProduct = new Product();
currentProduct.setProductFlags(ts);
......@@ -343,7 +343,7 @@ public class FoodWaveView extends GenericCDIView {
}
HashSet<Bill> billList = new HashSet<Bill>();
HashSet<Bill> billList = new HashSet<>();
for (BillLine line : getSelectedFoodWave().getBillLines()) {
if (!line.getBill().isPaid()) {
......@@ -351,11 +351,11 @@ public class FoodWaveView extends GenericCDIView {
}
}
bills = new ListDataModel<Bill>(new ArrayList<Bill>(billList));
bills = new ListDataModel<>(new ArrayList<>(billList));
accountEventLines = new ListDataModel<AccountEvent>(getSelectedFoodWave().getAccountEvents());
accountEventLines = new ListDataModel<>(getSelectedFoodWave().getAccountEvents());
}
......
......@@ -127,7 +127,7 @@ public class ProductShopView extends GenericCDIView {
return;
}
shoppingcart = new ListDataModel<ProductShopItem>(
shoppingcart = new ListDataModel<>(
ProductShopItem.productList(productBean.listUserShoppableProducts(), userView.getSelectedUser()));
for (ProductShopItem item : shoppingcart) {
......@@ -172,7 +172,7 @@ public class ProductShopView extends GenericCDIView {
public void initShopView() {
if (requirePermissions(ShopPermission.SHOP_TO_OTHERS) && shoppingcart == null) {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productGTList(productBean.findForStaffshop(), userView.getSelectedUser()));
shoppingcart = new ListDataModel<>(ProductShopItem.productGTList(productBean.findForStaffshop(), userView.getSelectedUser()));
updateCartLimits(null);
LanEventProperty cashdefault = eventbean.getProperty(LanEventPropertyKey.SHOP_DEFAULT_CASH);
......@@ -236,7 +236,7 @@ public class ProductShopView extends GenericCDIView {
public void updateCartLimits(ProductShopItem item) {
if (boughtItems == null) {
boughtItems = new ListDataModel<ProductShopItem>(new ArrayList<ProductShopItem>());
boughtItems = new ListDataModel<>(new ArrayList<>());
}
@SuppressWarnings("unchecked")
......@@ -246,7 +246,7 @@ public class ProductShopView extends GenericCDIView {
listdata.add(item);
}
Map<Integer, BigDecimal> prodCounts = new HashMap<Integer, BigDecimal>();
Map<Integer, BigDecimal> prodCounts = new HashMap<>();
for (ProductShopItem sc : shoppingcart) {
prodCounts.put(sc.getProduct().getId(), sc.getCount());
}
......@@ -438,9 +438,7 @@ public class ProductShopView extends GenericCDIView {
}
private boolean productsInCart() {
Iterator<ProductShopItem> nullcheckIter = shoppingcart.iterator();
while (nullcheckIter.hasNext()) {
ProductShopItem prod = nullcheckIter.next();
for (ProductShopItem prod : shoppingcart) {
// Autoproduct is not counted as a real product.
if (!prod.getProduct().getProductFlags().contains(ProductFlag.USERSHOP_AUTOPRODUCT) && prod.getCount().compareTo(BigDecimal.ZERO) > 0) {
return true;
......
......@@ -19,33 +19,16 @@
package fi.codecrew.moya.web.cdiview.shop;
import fi.codecrew.moya.beans.BillBeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.VerkkomaksutFiBeanLocal;
import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.entitysearch.BillSearchQuery;
import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.BillLine;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.utilities.SearchQuery.QuerySortOrder;
import fi.codecrew.moya.utilities.SearchResult;
import fi.codecrew.moya.utilities.jsf.MessageHelper;
import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.helpers.LazyEntityDataModel;
import org.primefaces.model.SortOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
@Named
@ConversationScoped
......
......@@ -160,7 +160,7 @@ public class ProductView extends GenericCDIView {
public String saveLimit()
{
if (product.getProductLimits() == null) {
product.setProductLimits(new ArrayList<ProductLimitation>());
product.setProductLimits(new ArrayList<>());
}
if (!product.getProductLimits().contains(limit)) {
product.getProductLimits().add(limit);
......@@ -217,13 +217,13 @@ public class ProductView extends GenericCDIView {
{
List<Discount> discs = product.getDiscounts();
discs.sort(Discount.SORT_COMPARATOR);
productDiscounts = new ListDataModel<Discount>(discs);
productDiscounts = new ListDataModel<>(discs);
return productDiscounts;
}
public ListDataModel<ProductLimitation> getProductLimits()
{
productLimits = new ListDataModel<ProductLimitation>(product.getProductLimits());
productLimits = new ListDataModel<>(product.getProductLimits());
return productLimits;
}
......
......@@ -49,7 +49,7 @@ public class SalespointListView extends GenericCDIView {
if (super.requirePermissions(SalespointPermission.VIEW)) {
beginConversation();
salespoints = new ListDataModel<Salespoint>(
salespoints = new ListDataModel<>(
salespointBean.findAll());
modifySalespoint = permbean
.hasPermission(SalespointPermission.MODIFY);
......
......@@ -42,17 +42,17 @@ public class UserCardWrapper implements Serializable {
if (user != null) {
cards = user.getPrintedCards();
}
printedCards = new ListDataModel<PrintedCard>(cards);
printedCards = new ListDataModel<>(cards);
}
public static ListDataModel<UserCardWrapper> initWrapper(List<User> users, UserBeanLocal userbean)
{
List<UserCardWrapper> ret = new ArrayList<UserCardWrapper>();
List<UserCardWrapper> ret = new ArrayList<>();
for (User u : users)
{
ret.add(new UserCardWrapper(u, userbean));
}
return new ListDataModel<UserCardWrapper>(ret);
return new ListDataModel<>(ret);
}
public EventUser getUser() {
......
......@@ -40,7 +40,7 @@ public class TournamentAddTeamView implements Serializable {
// Players
setPlayers(new ArrayList<String>());
setPlayers(new ArrayList<>());
getPlayers().add("");
getPlayers().add("");
getPlayers().add("");
......
......@@ -49,7 +49,7 @@ public class TournamentParticipantsView extends GenericCDIView {
if(eventUserGameID == null) {
this.tournament = tournamentBean.getTournamentById(tournamentId);
this.beginConversation();
eventUserGameID = new HashMap<Integer, String>();
eventUserGameID = new HashMap<>();
for(TournamentParticipant tp : tournament.getParticipants()) {
for(TournamentTeamMember ttm : tp.getTeamMembers()) {
GameID gid = userBean.getGameIDByGameAndUser(tournament.getTournamentGame(), ttm.getEventUser());
......
......@@ -114,7 +114,7 @@ public class TournamentParticipateView extends GenericCDIView {
tournamentParticipant = new TournamentParticipant();
tournamentParticipant.setTournament(tournament);
tournamentParticipant.setParticipator(permissionBean.getCurrentUser());
tournamentParticipant.setTeamMembers(new ArrayList<TournamentTeamMember>());
tournamentParticipant.setTeamMembers(new ArrayList<>());
TournamentTeamMember captain = new TournamentTeamMember();
captain.setRole(TournamentTeamMemberRole.CAPTAIN);
captain.setEventUser(permissionBean.getCurrentUser());
......
......@@ -19,44 +19,17 @@
package fi.codecrew.moya.web.cdiview.user;
import fi.codecrew.moya.beans.*;
import fi.codecrew.moya.enums.CardState;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.*;
import fi.codecrew.moya.rest.meta.v1.PrintedCardRestViewV1;
import fi.codecrew.moya.util.MassPrintResult;
import fi.codecrew.moya.utilities.jsf.MessageHelper;
import fi.codecrew.moya.web.annotations.LoggedIn;
import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.reader.ReaderView;
import fi.codecrew.moya.web.helper.LayoutView;
import org.primefaces.event.CaptureEvent;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.CroppedImage;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.primefaces.model.UploadedFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.EJB;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.inject.Produces;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import javax.inject.Inject;
import javax.inject.Named;
import javax.json.*;
import javax.json.stream.JsonGenerator;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Named()
@ConversationScoped
......@@ -116,11 +89,11 @@ public class CardHolderizeView extends GenericCDIView {
JsonObjectBuilder filingBuilder = Json.createObjectBuilder();
if (meta != null) {
meta.entrySet().forEach(e -> metaBuilder.add(e.getKey(), e.getValue()));
meta.forEach(metaBuilder::add);
JsonObject filingObj = meta.getJsonObject("card-filing");
if (filingObj != null) {
filingObj.entrySet().forEach(e -> filingBuilder.add(e.getKey(), e.getValue()));
filingObj.forEach(filingBuilder::add);
}
}
filingBuilder.add("cardplace", sb.toString());
......
......@@ -111,7 +111,7 @@ public class CardView extends GenericCDIView {
}
public List<CardTemplate> getTemplatesWithNull() {
ArrayList<CardTemplate> retlist = new ArrayList<CardTemplate>();
ArrayList<CardTemplate> retlist = new ArrayList<>();
CardTemplate dummytempl = new CardTemplate();
dummytempl.setName(I18n.get("cardTemplate.emptyCardTemplate"));
retlist.add(dummytempl);
......
......@@ -57,7 +57,7 @@ public class CreditTransferView extends GenericCDIView {
public void init(List<EventUser> users) {
ArrayList<EventUserWrapper> wrap = new ArrayList<EventUserWrapper>();
ArrayList<EventUserWrapper> wrap = new ArrayList<>();
for (EventUser u : users) {
wrap.add(new EventUserWrapper(u));
}
......@@ -84,7 +84,7 @@ public class CreditTransferView extends GenericCDIView {
}
public String commitTransfer() {
List<User> transfer = new ArrayList<User>();
List<User> transfer = new ArrayList<>();
for (EventUserWrapper u : users) {
if (!u.isSkip())
{
......
......@@ -18,7 +18,6 @@
*/
package fi.codecrew.moya.web.cdiview.user;
import java.io.IOException;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.util.ArrayList;
......@@ -81,7 +80,7 @@ public class ImportView extends GenericCDIView {
public String parse()
{
ArrayList<ImportWrapper> ret = new ArrayList<ImportWrapper>();
ArrayList<ImportWrapper> ret = new ArrayList<>();
byte[] bytes = FileUploadUtils.getFileContents(file);
......
......@@ -39,7 +39,7 @@ public class ImportWrapper implements Serializable {
public ImportWrapper(IUser usr) {
user = usr;
potential = new ArrayList<User>();
potential = new ArrayList<>();
selected = new User();
potential.add(selected);
}
......
......@@ -41,7 +41,7 @@ public class OrgRoleDataView extends GenericCDIView {
public ListDataModel<OrgRole> getOrgRoles() {
if (orgRoles == null) {
orgRoles = new ListDataModel<OrgRole>(orgRolesBean.listOrgRoles());
orgRoles = new ListDataModel<>(orgRolesBean.listOrgRoles());
}
return orgRoles;
......
......@@ -18,15 +18,6 @@
*/
package fi.codecrew.moya.web.cdiview.user;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.OrgRoleBeanLocal;
import fi.codecrew.moya.beans.RoleBeanLocal;
......@@ -34,10 +25,17 @@ import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.entitysearch.UserSearchQuery;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.OrgRole;
import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.User;
import fi.codecrew.moya.model.role.Role;
import fi.codecrew.moya.utilities.SearchResult;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import java.util.List;
@ConversationScoped
@Named
......
......@@ -18,20 +18,18 @@
*/
package fi.codecrew.moya.web.cdiview.user;
import java.util.List;
import fi.codecrew.moya.beans.RoleBeanLocal;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.role.Role;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.model.ListDataModel;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.RoleBeanLocal;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import java.util.List;
@Named
@RequestScoped
......@@ -72,7 +70,7 @@ public class RoleDataView extends GenericCDIView {
if (roles == null) {
List<Role> list = rolebean.listRoles();
list.add(0, Role.EMPTY_ROLE);
roles = new ListDataModel<Role>(list);
roles = new ListDataModel<>(list);
logger.info("rolecount {}", roles.getRowCount());
}
return roles;
......
......@@ -55,7 +55,7 @@ public class UserCardView extends GenericCDIView {
public ListDataModel<PrintedCard> getPrintedCards() {
if (printedCards == null && user != null)
{
printedCards = new ListDataModel<PrintedCard>(cardBean.getCards(user));
printedCards = new ListDataModel<>(cardBean.getCards(user));
}
return printedCards;
}
......
......@@ -21,7 +21,6 @@ package fi.codecrew.moya.web.cdiview.user;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.beans.UserPropertyBeanLocal;
import fi.codecrew.moya.model.*;
import fi.codecrew.moya.utilities.jsf.MessageHelper;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import org.primefaces.event.RowEditEvent;
import org.slf4j.Logger;
......
......@@ -61,7 +61,7 @@ public class UserOverviewView extends GenericCDIView {
public void initView() {
if (userOverviewItems == null) {
ArrayList<UserOverviewItem> ovlist = new ArrayList<UserOverviewItem>();
ArrayList<UserOverviewItem> ovlist = new ArrayList<>();
for (EventUser eu : getUserCartView().getUsercart()) {
PrintedCard pc = cardTemplateBean.checkPrintedCard(eu);
UserOverviewItem uoi = new UserOverviewItem(eu, pc, I18n.get("rejectcard.mailSubject"), I18n.get("rejectcard.mailBody"));
......
......@@ -204,7 +204,7 @@ public class UserSearchView extends PaginationView<UserWrapper> {
private List<UserWrapper> getUserWrappers(List<User> users)
{
ArrayList<UserWrapper> res = new ArrayList<UserWrapper>();
ArrayList<UserWrapper> res = new ArrayList<>();
for (User u : users) {
res.add(new UserWrapper(u, userbean.getEventUser(u, false)));
}
......
......@@ -42,7 +42,7 @@ public class VipListView extends PaginationView<Vip> {
public void initView() {
if (super.requirePermissions(VipPermission.VIEW) && viplist == null) {
viplist = new ListDataModel<Vip>(vipBean.getAvailableVips());
viplist = new ListDataModel<>(vipBean.getAvailableVips());
filteredVips = null;
super.beginConversation();
}
......
......@@ -18,8 +18,6 @@
*/
package fi.codecrew.moya.web.cdiview.voting;
import java.io.ByteArrayInputStream;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.model.ListDataModel;
......
......@@ -94,7 +94,7 @@ public class CompoMgmtView extends GenericCDIView {
for (CompoEntry e : entries) {
setCompo(votingBean.saveSort(e).getCompo());
}
entries = new ListDataModel<CompoEntry>(getCompo().getCompoEntries());
entries = new ListDataModel<>(getCompo().getCompoEntries());
return null;
}
......@@ -110,7 +110,7 @@ public class CompoMgmtView extends GenericCDIView {
public void initView() {
if (super.requirePermissions(CompoPermission.MANAGE) && entries == null) {
setCompo(votingBean.getCompoById(compoId));
entries = new ListDataModel<CompoEntry>(getCompo().getCompoEntries());
entries = new ListDataModel<>(getCompo().getCompoEntries());
super.beginConversation();
}
}
......
......@@ -18,11 +18,6 @@
*/
package fi.codecrew.moya.web.cdiview.voting;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import javax.ejb.EJB;
......@@ -31,10 +26,8 @@ import javax.enterprise.inject.Produces;
import javax.faces.model.ListDataModel;
import javax.inject.Named;
import fi.codecrew.moya.beans.RoleBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.*;
import fi.codecrew.moya.web.helpers.FileUploadUtils;
import org.primefaces.event.RateEvent;
import org.primefaces.model.UploadedFile;
import org.slf4j.Logger;
......
......@@ -58,7 +58,7 @@ public class EntryWrapper implements Serializable {
}
public static ListDataModel<EntryWrapper> init(List<CompoEntry> compoEntries, VotingBeanLocal votbean, boolean calcSummary) {
ArrayList<EntryWrapper> ret = new ArrayList<EntryWrapper>();
ArrayList<EntryWrapper> ret = new ArrayList<>();
for (CompoEntry entry : compoEntries)
{
if (entry.getSort() != null && entry.getSort() > 0)
......@@ -69,7 +69,7 @@ public class EntryWrapper implements Serializable {
}
}
return new ListDataModel<EntryWrapper>(ret);
return new ListDataModel<>(ret);
}
public CompoEntry getEntry() {
......
......@@ -18,8 +18,6 @@
*/
package fi.codecrew.moya.web.cdiview.voting;
import java.io.IOException;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
......
......@@ -27,7 +27,7 @@ import javax.inject.Named;
@Named("taskTypeConverter")
@RequestScoped
public class ActionlogTaskTypeConverter implements Converter {
public class ActionlogTaskTypeConverter implements Converter<Object> {
@Override
public Object getAsObject(FacesContext context, UIComponent component,
......
......@@ -30,18 +30,14 @@ import fi.codecrew.moya.enums.CardState;
@Named()
@RequestScoped
public class CardStateConverter implements Converter {
@EJB
private RoleBeanLocal rolebean;
public class CardStateConverter implements Converter<CardState> {
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
public CardState getAsObject(FacesContext context, UIComponent component, String value) {
return CardState.valueOf(value);
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
public String getAsString(FacesContext context, UIComponent component, CardState value) {
return value.toString();
}
}
......@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
@Named("emptytonullconverter")
@RequestScoped
public class EmptyToNullConverter implements Converter {
public class EmptyToNullConverter implements Converter<Object> {
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(EmptyToNullConverter.class);
......
......@@ -29,12 +29,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Named
public class LocaleConverter implements Converter {
public class LocaleConverter implements Converter<Locale> {
private static final Logger logger = LoggerFactory.getLogger(LocaleConverter.class);
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
public Locale getAsObject(FacesContext context, UIComponent component, String value) {
Locale ret = null;
if (value != null && !value.isEmpty() && !"null".equals(value)) {
try {
......@@ -48,7 +48,7 @@ public class LocaleConverter implements Converter {
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
public String getAsString(FacesContext context, UIComponent component, Locale value) {
String ret = "null";
if (value != null && value instanceof Locale) {
Locale loc = (Locale) value;
......
......@@ -31,7 +31,7 @@ import fi.codecrew.moya.model.PossibleAnswer;
@Named("pollAnswerConverter")
@RequestScoped()
public class PollAnswerConverter implements Converter {
public class PollAnswerConverter implements Converter<PollAnswer> {
@EJB
private PollBeanLocal pollbean;
......@@ -40,7 +40,7 @@ public class PollAnswerConverter implements Converter {
}
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
public PollAnswer getAsObject(FacesContext context, UIComponent component, String value) {
PossibleAnswer possibleAnswer = pollbean.findPossibleAnwerById(Integer.parseInt(value));
PollAnswer ret = new PollAnswer();
......@@ -50,15 +50,8 @@ public class PollAnswerConverter implements Converter {
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
String ret = null;
if (value instanceof PollAnswer) {
ret = ((PollAnswer) value).getChoice().getId().toString();
}
return ret;
public String getAsString(FacesContext context, UIComponent component, PollAnswer value) {
return value.getChoice().getId().toString();
}
}
......@@ -28,17 +28,15 @@ import fi.codecrew.moya.model.ProductFlag;
@Named("productFlagConverter")
@RequestScoped()
public class ProductFlagConverter implements Converter {
public class ProductFlagConverter implements Converter<ProductFlag> {
@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
// TODO Auto-generated method stub
public ProductFlag getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
return ProductFlag.valueOf(arg2);
}
@Override
public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
// TODO Auto-generated method stub
public String getAsString(FacesContext arg0, UIComponent arg1, ProductFlag arg2) {
return arg2.toString();
}
......
......@@ -19,7 +19,6 @@
package fi.codecrew.moya.web.converter;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.ProductOption;
import fi.codecrew.moya.utilities.jsf.GenericIntegerEntityConverter;
import org.slf4j.Logger;
......
......@@ -18,14 +18,14 @@
*/
package fi.codecrew.moya.web.converter;
import fi.codecrew.moya.beans.RoleBeanLocal;
import fi.codecrew.moya.model.role.Role;
import fi.codecrew.moya.utilities.jsf.GenericIntegerEntityConverter;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.RoleBeanLocal;
import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.utilities.jsf.GenericIntegerEntityConverter;
@Named("roleConverter")
@RequestScoped
public class RoleConverter extends GenericIntegerEntityConverter<Role> {
......
......@@ -29,7 +29,7 @@ import fi.codecrew.moya.beans.SessionMgmtBeanLocal.UserContainer;
import fi.codecrew.moya.utilities.I18n;
@Named()
public class SessionToHostnameConverter implements Converter {
public class SessionToHostnameConverter implements Converter<Object> {
@EJB
private SessionMgmtBeanLocal sessbean;
......
......@@ -29,7 +29,7 @@ import fi.codecrew.moya.beans.SessionMgmtBeanLocal.UserContainer;
import fi.codecrew.moya.utilities.I18n;
@Named()
public class SessionToUsernameConverter implements Converter {
public class SessionToUsernameConverter implements Converter<Object> {
@EJB
private SessionMgmtBeanLocal sessbean;
......
......@@ -41,7 +41,6 @@ import javax.inject.Named;
import javax.json.JsonObject;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
@Named
@ConversationScoped
......@@ -286,7 +285,7 @@ public class IncomingView extends GenericCDIView {
}
public ListDataModel<GroupMembership> getGroupMemberships() {
memberlist = new ListDataModel<GroupMembership>(ticketBean.findMembershipPrintlistForUser(userview.getSelectedUser()));
memberlist = new ListDataModel<>(ticketBean.findMembershipPrintlistForUser(userview.getSelectedUser()));
return memberlist;
}
......@@ -320,9 +319,9 @@ public class IncomingView extends GenericCDIView {
public ListDataModel<CardCode> getCardCodes() {
if (userview.getPrintedCard() == null)
return new ListDataModel<CardCode>(new ArrayList<CardCode>());
return new ListDataModel<>(new ArrayList<>());
cardCodes = new ListDataModel<CardCode>(userview.getPrintedCard().getCardCodes());
cardCodes = new ListDataModel<>(userview.getPrintedCard().getCardCodes());
return cardCodes;
}
......
......@@ -5,7 +5,6 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
import javax.enterprise.context.ConversationScoped;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import java.io.Serializable;
import java.util.Map;
/**
......
......@@ -64,10 +64,10 @@ public class FeedbackView extends GenericCDIView {
public ListDataModel<Feedback> getFeedbacks() {
if (feedbacks == null && permissionBean.getCurrentUser().isSuperadmin())
{
feedbacks = new ListDataModel<Feedback>(userbean.getFeedbacks());
feedbacks = new ListDataModel<>(userbean.getFeedbacks());
}
else {
feedbacks = new ListDataModel<Feedback>();
feedbacks = new ListDataModel<>();
}
return feedbacks;
}
......
......@@ -41,7 +41,7 @@ public class FieldsetView extends GenericCDIView {
private HashMap<String, Boolean> collapseStates = new HashMap<String, Boolean>();
private HashMap<String, Boolean> collapseStates = new HashMap<>();
public boolean isCollapsed(String id) {
......
......@@ -135,7 +135,7 @@ public class HttpSessionWrapper
}
ret.add(new HttpSessionWrapper(s, username, hostname));
}
Collections.sort(ret, new LastSeenComparator());
ret.sort(new LastSeenComparator());
return ret;
}
......
......@@ -58,7 +58,7 @@ public class ProductShopItemHelper extends GenericCDIView {
item.setInternalDiscounts(discountBean.getActiveDiscountsByProduct(item.getProduct(), item.getCount(),
new Date(), item.getUser()));
item.setInternalDiscountValues(new HashMap<Integer, BigDecimal>());
item.setInternalDiscountValues(new HashMap<>());
for (Discount d : item.getDiscounts()) {
BigDecimal newprice = item.getPrice().multiply(d.getPercentage());
......
......@@ -39,7 +39,7 @@ public class ThemeSwitcherView extends GenericCDIView {
public Map<String, String> getThemes() {
if (themes == null) {
themes = new TreeMap<String, String>();
themes = new TreeMap<>();
themes.put("Afterdark", "afterdark");
themes.put("Afternoon", "afternoon");
themes.put("Afterwork", "afterwork");
......
......@@ -36,14 +36,14 @@ public class BortalApplicationWrapper implements Serializable {
*/
private static final long serialVersionUID = -5552828911388714876L;
private final ArrayList<IAppPermission> permissions;
private Set<String> selected = new HashSet<String>();
private Set<String> selected = new HashSet<>();
private final BortalApplication app;
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(BortalApplicationWrapper.class);
public BortalApplicationWrapper(BortalApplication bApp, Set<IAppPermission> set) {
app = bApp;
permissions = new ArrayList<IAppPermission>();
permissions = new ArrayList<>();
for (IAppPermission ap : bApp.getPermissions()) {
boolean has = set != null && set.contains(ap);
......
......@@ -92,7 +92,7 @@ public class LectureGroupView extends GenericCDIView {
public ListDataModel<LectureGroup> getLectureGroups() {
if (lectureGroupModel == null) {
lectureGroupModel = new ListDataModel<LectureGroup>(lectureBean.getLectureGroups());
lectureGroupModel = new ListDataModel<>(lectureBean.getLectureGroups());
}
return lectureGroupModel;
......
......@@ -92,7 +92,7 @@ public class LectureReportsView extends GenericCDIView {
}
public ListDataModel<LectureGroup> getLectureGroups() {
lectureGroups = new ListDataModel<LectureGroup>(lectureBean.getLectureGroups());
lectureGroups = new ListDataModel<>(lectureBean.getLectureGroups());
return lectureGroups;
}
......@@ -117,10 +117,10 @@ public class LectureReportsView extends GenericCDIView {
public ListDataModel<Lecture> getLectures() {
if (currentLectureGroup == null)
return new ListDataModel<Lecture>();
return new ListDataModel<>();
if(lectures == null)
lectures = new ListDataModel<Lecture>(lectureBean.getLecturesByLectureGroup(getCurrentLectureGroup()));
lectures = new ListDataModel<>(lectureBean.getLecturesByLectureGroup(getCurrentLectureGroup()));
return lectures;
}
......@@ -140,7 +140,7 @@ public class LectureReportsView extends GenericCDIView {
public List<String> getEmptyLinesList() {
ArrayList<String> retList = new ArrayList<String>();
ArrayList<String> retList = new ArrayList<>();
for(int n = getCurrentLecture().getParticipantsCount(); n < getCurrentLecture().getMaxParticipantsCount(); n++) {
retList.add(""+(n+1)+":");
}
......
......@@ -83,7 +83,7 @@ public class LectureUserView extends GenericCDIView {
}
public ListDataModel<LectureGroup> getLectureGroups() {
lectureGroups = new ListDataModel<LectureGroup>(lectureBean.getLectureGroups());
lectureGroups = new ListDataModel<>(lectureBean.getLectureGroups());
return lectureGroups;
}
......@@ -108,16 +108,16 @@ public class LectureUserView extends GenericCDIView {
public ListDataModel<Lecture> getLectures() {
if (currentLectureGroup == null)
return new ListDataModel<Lecture>();
return new ListDataModel<>();
if (lectures == null)
lectures = new ListDataModel<Lecture>(lectureBean.findAvailableLectures(getCurrentLectureGroup(), userView.getCurrentUser()));
lectures = new ListDataModel<>(lectureBean.findAvailableLectures(getCurrentLectureGroup(), userView.getCurrentUser()));
return lectures;
}
public ListDataModel<Lecture> getParticipatedLectures() {
participatedLectures = new ListDataModel<Lecture>(lectureBean.getParticipatedLectures(userView.getCurrentUser()));
participatedLectures = new ListDataModel<>(lectureBean.getParticipatedLectures(userView.getCurrentUser()));
return participatedLectures;
}
......
......@@ -120,7 +120,7 @@ public class LectureView extends GenericCDIView {
public ListDataModel<Lecture> getLectures() {
if (lectures == null && getCurrentLectureGroup() != null) {
lectures = new ListDataModel<Lecture>(getCurrentLectureGroup().getLectures());
lectures = new ListDataModel<>(getCurrentLectureGroup().getLectures());
}
return lectures;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!