You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mb...@apache.org on 2017/12/16 17:44:10 UTC
svn commit: r1818442 -
/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/
Author: mbrohl
Date: Sat Dec 16 17:44:09 2017
New Revision: 1818442
URL: http://svn.apache.org/viewvc?rev=1818442&view=rev
Log:
Improved: General refactoring and code improvements, package
org.apache.ofbiz.workeffort.workeffort.
(OFBIZ-9961)
Thanks Dennis Balkir for reporting and providing the patches.
Modified:
ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java
ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalHandlerFactory.java
ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java
ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java
ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java
ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortPartyAssignmentServices.java
ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java
ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java
ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java
ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java
ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortWorker.java
Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java?rev=1818442&r1=1818441&r2=1818442&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java Sat Dec 16 17:44:09 2017
@@ -149,7 +149,7 @@ public class ICalConverter {
}
protected static ResponseProperties createWorkEffort(Component component, Map<String, Object> context) {
- Map<String, Object> serviceMap = new HashMap<String, Object>();
+ Map<String, Object> serviceMap = new HashMap<>();
setWorkEffortServiceMap(component, serviceMap);
serviceMap.put("workEffortTypeId", "VTODO".equals(component.getName()) ? "TASK" : "EVENT");
serviceMap.put("currentStatusId", "VTODO".equals(component.getName()) ? "CAL_NEEDS_ACTION" : "CAL_TENTATIVE");
@@ -437,7 +437,7 @@ public class ICalConverter {
}
}
- protected static List<GenericValue> getRelatedWorkEfforts(GenericValue workEffort, Map<String, Object> context) throws GenericEntityException {
+ protected static List<GenericValue> getRelatedWorkEfforts(GenericValue workEffort, Map<String, Object> context) {
Map<String, ? extends Object> serviceMap = UtilMisc.toMap("workEffortId", workEffort.getString("workEffortId"));
Map<String, Object> resultMap = invokeService("getICalWorkEfforts", serviceMap, context);
List<GenericValue> workEfforts = UtilGenerics.checkList(resultMap.get("workEfforts"), GenericValue.class);
@@ -456,15 +456,14 @@ public class ICalConverter {
Boolean hasPermission = (Boolean) serviceResult.get("hasPermission");
if (hasPermission != null) {
return hasPermission.booleanValue();
- } else {
- return false;
}
+ return false;
}
protected static Map<String, Object> invokeService(String serviceName, Map<String, ? extends Object> serviceMap, Map<String, Object> context) {
LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher");
Locale locale = (Locale) context.get("locale");
- Map<String, Object> localMap = new HashMap<String, Object>();
+ Map<String, Object> localMap = new HashMap<>();
try {
ModelService modelService = null;
modelService = dispatcher.getDispatchContext().getModelService(serviceName);
@@ -721,7 +720,7 @@ public class ICalConverter {
}
boolean hasCreatePermission = hasPermission(workEffortId, "CREATE", context);
List<GenericValue> workEfforts = getRelatedWorkEfforts(publishProperties, context);
- Set<String> validWorkEfforts = new HashSet<String>();
+ Set<String> validWorkEfforts = new HashSet<>();
if (UtilValidate.isNotEmpty(workEfforts)) {
// Security issue: make sure only related work efforts get updated
for (GenericValue workEffort : workEfforts) {
@@ -775,8 +774,8 @@ public class ICalConverter {
protected static ResponseProperties storePartyAssignments(String workEffortId, Component component, Map<String, Object> context) {
ResponseProperties responseProps = null;
- Map<String, Object> serviceMap = new HashMap<String, Object>();
- List<Property> partyList = new LinkedList<Property>();
+ Map<String, Object> serviceMap = new HashMap<>();
+ List<Property> partyList = new LinkedList<>();
partyList.addAll(UtilGenerics.checkList(component.getProperties("ATTENDEE"), Property.class));
partyList.addAll(UtilGenerics.checkList(component.getProperties("CONTACT"), Property.class));
partyList.addAll(UtilGenerics.checkList(component.getProperties("ORGANIZER"), Property.class));
@@ -817,7 +816,7 @@ public class ICalConverter {
return responseProps;
}
- protected static ResponseProperties storeWorkEffort(Component component, Map<String, Object> context) throws GenericEntityException, GenericServiceException {
+ protected static ResponseProperties storeWorkEffort(Component component, Map<String, Object> context) throws GenericEntityException {
PropertyList propertyList = component.getProperties();
String workEffortId = fromXProperty(propertyList, workEffortIdXPropName);
Delegator delegator = (Delegator) context.get("delegator");
@@ -828,7 +827,7 @@ public class ICalConverter {
if (!hasPermission(workEffortId, "UPDATE", context)) {
return null;
}
- Map<String, Object> serviceMap = new HashMap<String, Object>();
+ Map<String, Object> serviceMap = new HashMap<>();
serviceMap.put("workEffortId", workEffortId);
setWorkEffortServiceMap(component, serviceMap);
invokeService("updateWorkEffort", serviceMap, context);
Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalHandlerFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalHandlerFactory.java?rev=1818442&r1=1818441&r2=1818442&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalHandlerFactory.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalHandlerFactory.java Sat Dec 16 17:44:09 2017
@@ -44,7 +44,7 @@ public class ICalHandlerFactory implemen
protected final RequestHandler doNothingHandler = new DoNothingHandler();
public ICalHandlerFactory() {
- this.handlerMap = new HashMap<String, RequestHandler>();
+ this.handlerMap = new HashMap<>();
this.handlerMap.put("COPY", doNothingHandler);
this.handlerMap.put("DELETE", doNothingHandler);
this.handlerMap.put("GET", new GetHandler());
Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java?rev=1818442&r1=1818441&r2=1818442&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java Sat Dec 16 17:44:09 2017
@@ -88,23 +88,23 @@ public class ICalRecurConverter implemen
}
protected DtStart dateStart = null;
- protected List<DateListProperty> incDateList = new LinkedList<DateListProperty>();
- protected List<DateListProperty> exDateList = new LinkedList<DateListProperty>();
- protected List<RRule> incRuleList = new LinkedList<RRule>();
- protected List<ExRule> exRuleList = new LinkedList<ExRule>();
+ protected List<DateListProperty> incDateList = new LinkedList<>();
+ protected List<DateListProperty> exDateList = new LinkedList<>();
+ protected List<RRule> incRuleList = new LinkedList<>();
+ protected List<ExRule> exRuleList = new LinkedList<>();
protected VisitorState state = new VisitorState();
- protected Stack<VisitorState> stateStack = new Stack<VisitorState>();
+ protected Stack<VisitorState> stateStack = new Stack<>();
protected ICalRecurConverter() {}
@SuppressWarnings("unchecked")
protected Recur consolidateRecurs(List<Recur> recurList) {
// Try to consolidate a list of Recur instances into one instance
- Set<Integer> monthList = new HashSet<Integer>();
- Set<Integer> monthDayList = new HashSet<Integer>();
- Set<WeekDay> weekDayList = new HashSet<WeekDay>();
- Set<Integer> hourList = new HashSet<Integer>();
- Set<Integer> minuteList = new HashSet<Integer>();
+ Set<Integer> monthList = new HashSet<>();
+ Set<Integer> monthDayList = new HashSet<>();
+ Set<WeekDay> weekDayList = new HashSet<>();
+ Set<Integer> hourList = new HashSet<>();
+ Set<Integer> minuteList = new HashSet<>();
String freq = null;
int freqCount = 0;
for (Recur recur : recurList) {
@@ -322,8 +322,8 @@ public class ICalRecurConverter implemen
protected class VisitorState {
public boolean isExcluded = false;
public boolean isIntersection = false;
- public List<Recur> inclRecurList = new LinkedList<Recur>();
- public List<Recur> exRecurList = new LinkedList<Recur>();
+ public List<Recur> inclRecurList = new LinkedList<>();
+ public List<Recur> exRecurList = new LinkedList<>();
public void addRecur(Recur recur) {
if (this.isIntersection) {
if (this.isExcluded) {
Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java?rev=1818442&r1=1818441&r2=1818442&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java Sat Dec 16 17:44:09 2017
@@ -29,7 +29,6 @@ import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@@ -74,7 +73,7 @@ public final class ICalWorker {
}
private static Map<String, Object> createConversionContext(HttpServletRequest request) {
- Map<String, Object> context = new HashMap<String, Object>();
+ Map<String, Object> context = new HashMap<>();
Enumeration<String> attributeEnum = UtilGenerics.cast(request.getAttributeNames());
while (attributeEnum.hasMoreElements()) {
String attributeName = attributeEnum.nextElement();
@@ -92,7 +91,7 @@ public final class ICalWorker {
*
* @param statusMessage Optional status message - usually <code>null</code>
* for security reasons
- * @return Create an HTTP Forbidden response
+ * @return Create an HTTP Forbidden response
*/
public static ResponseProperties createForbiddenResponse(String statusMessage) {
return new ResponseProperties(HttpServletResponse.SC_FORBIDDEN, statusMessage);
@@ -137,12 +136,11 @@ public final class ICalWorker {
GenericValue iCalData = publishProperties.getRelatedOne("WorkEffortIcalData", false);
if (iCalData != null) {
return iCalData.getTimestamp("lastUpdatedStamp");
- } else {
- return publishProperties.getTimestamp("lastUpdatedStamp");
}
+ return publishProperties.getTimestamp("lastUpdatedStamp");
}
- public static void handleGetRequest(HttpServletRequest request, HttpServletResponse response, ServletContext context) throws ServletException, IOException {
+ public static void handleGetRequest(HttpServletRequest request, HttpServletResponse response, ServletContext context) throws IOException {
if (!isValidRequest(request, response)) {
return;
}
@@ -162,7 +160,7 @@ public final class ICalWorker {
writeResponse(responseProps, request, response, context);
}
- public static void handlePropFindRequest(HttpServletRequest request, HttpServletResponse response, ServletContext context) throws ServletException, IOException {
+ public static void handlePropFindRequest(HttpServletRequest request, HttpServletResponse response, ServletContext context) throws IOException {
if (!isValidRequest(request, response)) {
return;
}
@@ -176,8 +174,8 @@ public final class ICalWorker {
PropFindHelper helper = new PropFindHelper(requestDocument);
if (!helper.isAllProp() && !helper.isPropName()) {
Document responseDocument = helper.getResponseDocument();
- List<Element> supportedProps = new LinkedList<Element>();
- List<Element> unSupportedProps = new LinkedList<Element>();
+ List<Element> supportedProps = new LinkedList<>();
+ List<Element> unSupportedProps = new LinkedList<>();
List<Element> propElements = helper.getFindPropsList(ResponseHelper.DAV_NAMESPACE_URI);
for (Element propElement : propElements) {
if ("getetag".equals(propElement.getNodeName())) {
@@ -222,7 +220,7 @@ public final class ICalWorker {
response.flushBuffer();
}
- public static void handlePutRequest(HttpServletRequest request, HttpServletResponse response, ServletContext context) throws ServletException, IOException {
+ public static void handlePutRequest(HttpServletRequest request, HttpServletResponse response, ServletContext context) throws IOException {
if (!isValidRequest(request, response)) {
return;
}
Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java?rev=1818442&r1=1818441&r2=1818442&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java Sat Dec 16 17:44:09 2017
@@ -43,10 +43,14 @@ import org.apache.ofbiz.entity.util.Enti
public class WorkEffortKeywordIndex {
public static final String module = WorkEffortKeywordIndex.class.getName();
public static void indexKeywords(GenericValue workEffort) throws GenericEntityException {
- if (workEffort == null) return;
+ if (workEffort == null) {
+ return;
+ }
Delegator delegator = workEffort.getDelegator();
- if (delegator == null) return;
+ if (delegator == null) {
+ return;
+ }
String workEffortId = workEffort.getString("workEffortId");
String separators = KeywordSearchUtil.getSeparators();
String stopWordBagOr = KeywordSearchUtil.getStopWordBagOr();
@@ -54,8 +58,8 @@ public class WorkEffortKeywordIndex {
boolean removeStems = KeywordSearchUtil.getRemoveStems();
Set<String> stemSet = KeywordSearchUtil.getStemSet();
- Map<String, Long> keywords = new TreeMap<String, Long>();
- List<String> strings = new LinkedList<String>();
+ Map<String, Long> keywords = new TreeMap<>();
+ List<String> strings = new LinkedList<>();
int widWeight = 1;
try {
widWeight = EntityUtilProperties.getPropertyAsInteger("workeffort", "index.weight.WorkEffort.workEffortId", 1).intValue();
@@ -108,7 +112,7 @@ public class WorkEffortKeywordIndex {
KeywordSearchUtil.processKeywordsForIndex(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet);
}
- List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+ List<GenericValue> toBeStored = new LinkedList<>();
for (Map.Entry<String, Long> entry: keywords.entrySet()) {
if (entry.getKey().length() < 60) { // ignore very long strings, cannot be stored anyway
GenericValue workEffortKeyword = delegator.makeValue("WorkEffortKeyword", UtilMisc.toMap("workEffortId", workEffort.getString("workEffortId"), "keyword", entry.getKey(), "relevancyWeight", entry.getValue()));
@@ -116,7 +120,9 @@ public class WorkEffortKeywordIndex {
}
}
if (toBeStored.size() > 0) {
- if (Debug.verboseOn()) Debug.logVerbose("WorkEffortKeywordIndex indexKeywords Storing " + toBeStored.size() + " keywords for workEffortId " + workEffort.getString("workEffortId"), module);
+ if (Debug.verboseOn()) {
+ Debug.logVerbose("WorkEffortKeywordIndex indexKeywords Storing " + toBeStored.size() + " keywords for workEffortId " + workEffort.getString("workEffortId"), module);
+ }
delegator.storeAll(toBeStored);
}
@@ -129,10 +135,8 @@ public class WorkEffortKeywordIndex {
for (int i = 0; i < weight; i++) {
strings.add(contentText);
}
- } catch (IOException e1) {
- Debug.logError(e1, "Error getting content text to index", module);
- } catch (GeneralException e1) {
- Debug.logError(e1, "Error getting content text to index", module);
+ } catch (IOException | GeneralException e) {
+ Debug.logError(e, "Error getting content text to index", module);
}
}
public static void addWeightedKeywordSourceString(GenericValue value, String fieldName, List<String> strings) {
Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortPartyAssignmentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortPartyAssignmentServices.java?rev=1818442&r1=1818441&r2=1818442&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortPartyAssignmentServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortPartyAssignmentServices.java Sat Dec 16 17:44:09 2017
@@ -61,8 +61,9 @@ public class WorkEffortPartyAssignmentSe
try {
Map<String, Object> results = dispatcher.runSync("wfAcceptAssignment", context);
- if (results != null && results.get(ModelService.ERROR_MESSAGE) != null)
+ if (results != null && results.get(ModelService.ERROR_MESSAGE) != null) {
Debug.logWarning((String) results.get(ModelService.ERROR_MESSAGE), module);
+ }
} catch (GenericServiceException e) {
Debug.logWarning(e, module);
}
@@ -71,8 +72,9 @@ public class WorkEffortPartyAssignmentSe
try {
Map<String, Object> results = dispatcher.runSync("wfCompleteAssignment", context);
- if (results != null && results.get(ModelService.ERROR_MESSAGE) != null)
+ if (results != null && results.get(ModelService.ERROR_MESSAGE) != null) {
Debug.logWarning((String) results.get(ModelService.ERROR_MESSAGE), module);
+ }
} catch (GenericServiceException e) {
Debug.logWarning(e, module);
}
@@ -81,8 +83,9 @@ public class WorkEffortPartyAssignmentSe
try {
Map<String, Object> results = dispatcher.runSync("wfDeclineAssignment", context);
- if (results != null && results.get(ModelService.ERROR_MESSAGE) != null)
+ if (results != null && results.get(ModelService.ERROR_MESSAGE) != null) {
Debug.logWarning((String) results.get(ModelService.ERROR_MESSAGE), module);
+ }
} catch (GenericServiceException e) {
Debug.logWarning(e, module);
}
Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java?rev=1818442&r1=1818441&r2=1818442&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java Sat Dec 16 17:44:09 2017
@@ -133,17 +133,17 @@ public class WorkEffortSearch {
public static class WorkEffortSearchContext {
public int index = 1;
- public List<EntityCondition> entityConditionList = new LinkedList<EntityCondition>();
- public List<String> orderByList = new LinkedList<String>();
+ public List<EntityCondition> entityConditionList = new LinkedList<>();
+ public List<String> orderByList = new LinkedList<>();
public List<String> fieldsToSelect = UtilMisc.toList("workEffortId");
public DynamicViewEntity dynamicViewEntity = new DynamicViewEntity();
public boolean workEffortIdGroupBy = false;
public boolean includedKeywordSearch = false;
public Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
- public List<Set<String>> keywordFixedOrSetAndList = new LinkedList<Set<String>>();
- public Set<String> orKeywordFixedSet = new HashSet<String>();
- public Set<String> andKeywordFixedSet = new HashSet<String>();
- public List<GenericValue> workEffortSearchConstraintList = new LinkedList<GenericValue>();
+ public List<Set<String>> keywordFixedOrSetAndList = new LinkedList<>();
+ public Set<String> orKeywordFixedSet = new HashSet<>();
+ public Set<String> andKeywordFixedSet = new HashSet<>();
+ public List<GenericValue> workEffortSearchConstraintList = new LinkedList<>();
public ResultSortOrder resultSortOrder = null;
public Integer resultOffset = null;
public Integer maxResults = null;
@@ -268,7 +268,7 @@ public class WorkEffortSearch {
dynamicViewEntity.addMemberEntity(entityAlias, "WorkEffortKeyword");
dynamicViewEntity.addAlias(entityAlias, prefix + "Keyword", "keyword", null, null, null, null);
dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("workEffortId"));
- List<EntityExpr> keywordOrList = new LinkedList<EntityExpr>();
+ List<EntityExpr> keywordOrList = new LinkedList<>();
for (String keyword: keywordFixedOrSet) {
keywordOrList.add(EntityCondition.makeCondition(prefix + "Keyword", EntityOperator.LIKE, keyword));
}
@@ -292,7 +292,7 @@ public class WorkEffortSearch {
/**
* @param delegator the delegator
* @return EntityListIterator representing the result of the query: NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE
- * DONE WITH IT (preferably in a finally block),
+ * DONE WITH IT (preferably in a finally block),
* AND DON'T LEAVE IT OPEN TOO LONG BECAUSE IT WILL MAINTAIN A DATABASE CONNECTION.
*/
public EntityListIterator doQuery(Delegator delegator) {
@@ -327,7 +327,7 @@ public class WorkEffortSearch {
}
public ArrayList<String> makeWorkEffortIdList(EntityListIterator eli) {
- ArrayList<String> workEffortIds = new ArrayList<String>(maxResults == null ? 100 : maxResults.intValue());
+ ArrayList<String> workEffortIds = new ArrayList<>(maxResults == null ? 100 : maxResults.intValue());
if (eli == null) {
Debug.logWarning("The eli is null, returning zero results", module);
return workEffortIds;
@@ -342,7 +342,9 @@ public class WorkEffortSearch {
hasResults = true;
}
if (resultOffset != null && resultOffset.intValue() > 1) {
- if (Debug.infoOn()) Debug.logInfo("Before relative, current index=" + eli.currentIndex(), module);
+ if (Debug.infoOn()) {
+ Debug.logInfo("Before relative, current index=" + eli.currentIndex(), module);
+ }
hasResults = eli.relative(resultOffset.intValue() - 1);
initialResult = null;
}
@@ -372,7 +374,7 @@ public class WorkEffortSearch {
int numRetreived = 1;
int duplicatesFound = 0;
- Set<String> workEffortIdSet = new HashSet<String>();
+ Set<String> workEffortIdSet = new HashSet<>();
workEffortIds.add(searchResult.getString("workEffortId"));
workEffortIdSet.add(searchResult.getString("workEffortId"));
@@ -479,7 +481,7 @@ public class WorkEffortSearch {
@Override
public void addConstraint(WorkEffortSearchContext workEffortSearchContext) {
- Set<String> workEffortIdSet = new HashSet<String>();
+ Set<String> workEffortIdSet = new HashSet<>();
if (includeSubWorkEfforts) {
// find all sub-categories recursively, make a Set of workEffortId
WorkEffortSearch.getAllSubWorkEffortIds(workEffortId, workEffortIdSet, workEffortSearchContext.getDelegator(), workEffortSearchContext.nowTimestamp);
@@ -506,7 +508,7 @@ public class WorkEffortSearch {
workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ThruDate", "thruDate", null, null, null, null);
workEffortSearchContext.dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.TRUE, ModelKeyMap.makeKeyMapList("workEffortId","workEffortIdFrom"));
- List<EntityExpr> assocConditionFromTo = new LinkedList<EntityExpr>();
+ List<EntityExpr> assocConditionFromTo = new LinkedList<>();
assocConditionFromTo.add(EntityCondition.makeCondition(prefix + "WorkEffortIdTo", EntityOperator.IN, workEffortIdSet));
if (UtilValidate.isNotEmpty(workEffortAssocTypeId)) {
assocConditionFromTo.add(EntityCondition.makeCondition(prefix + "WorkEffortAssocTypeId", EntityOperator.EQUALS, workEffortAssocTypeId));
@@ -527,7 +529,7 @@ public class WorkEffortSearch {
workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ThruDate", "thruDate", null, null, null, null);
workEffortSearchContext.dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.TRUE, ModelKeyMap.makeKeyMapList("workEffortId","workEffortIdTo"));
- List<EntityExpr> assocConditionToFrom = new LinkedList<EntityExpr>();
+ List<EntityExpr> assocConditionToFrom = new LinkedList<>();
assocConditionToFrom.add(EntityCondition.makeCondition(prefix + "WorkEffortIdFrom", EntityOperator.IN, workEffortIdSet));
if (UtilValidate.isNotEmpty(workEffortAssocTypeId)) {
assocConditionToFrom.add(EntityCondition.makeCondition(prefix + "WorkEffortAssocTypeId", EntityOperator.EQUALS, workEffortAssocTypeId));
@@ -930,11 +932,11 @@ public class WorkEffortSearch {
public Set<String> makeFullKeywordSet(Delegator delegator) {
Set<String> keywordSet = KeywordSearchUtil.makeKeywordSet(this.keywordsString, null, true);
- Set<String> fullKeywordSet = new TreeSet<String>();
+ Set<String> fullKeywordSet = new TreeSet<>();
// expand the keyword list according to the thesaurus and create a new set of keywords
for (String keyword: keywordSet) {
- Set<String> expandedSet = new TreeSet<String>();
+ Set<String> expandedSet = new TreeSet<>();
boolean replaceEntered = KeywordSearchUtil.expandKeywordForSearch(keyword, expandedSet, delegator);
fullKeywordSet.addAll(expandedSet);
if (!replaceEntered) {
@@ -959,13 +961,13 @@ public class WorkEffortSearch {
// expand the keyword list according to the thesaurus and create a new set of keywords
for (String keyword: keywordSet) {
- Set<String> expandedSet = new TreeSet<String>();
+ Set<String> expandedSet = new TreeSet<>();
boolean replaceEntered = KeywordSearchUtil.expandKeywordForSearch(keyword, expandedSet, workEffortSearchContext.getDelegator());
if (!replaceEntered) {
expandedSet.add(keyword);
}
Set<String> fixedSet = KeywordSearchUtil.fixKeywordsForSearch(expandedSet, anyPrefix, anySuffix, removeStems, isAnd);
- Set<String> fixedKeywordSet = new HashSet<String>();
+ Set<String> fixedKeywordSet = new HashSet<>();
fixedKeywordSet.addAll(fixedSet);
workEffortSearchContext.keywordFixedOrSetAndList.add(fixedKeywordSet);
}
Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java?rev=1818442&r1=1818441&r2=1818442&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java Sat Dec 16 17:44:09 2017
@@ -52,9 +52,13 @@ public class WorkEffortSearchEvents {
WorkEffortSearchOptions workEffortSearchOptions = WorkEffortSearchSession.getWorkEffortSearchOptions(session);
Integer viewIndexInteger = workEffortSearchOptions.getViewIndex();
- if (viewIndexInteger != null) viewIndex = viewIndexInteger.intValue();
+ if (viewIndexInteger != null) {
+ viewIndex = viewIndexInteger.intValue();
+ }
Integer viewSizeInteger = workEffortSearchOptions.getViewSize();
- if (viewSizeInteger != null) viewSize = viewSizeInteger.intValue();
+ if (viewSizeInteger != null) {
+ viewSize = viewSizeInteger.intValue();
+ }
lowIndex = viewIndex * viewSize;
highIndex = (viewIndex + 1) * viewSize;
@@ -98,7 +102,7 @@ public class WorkEffortSearchEvents {
String searchSortOrderString = WorkEffortSearchSession.searchGetSortOrderString(false, request);
// ========== populate the result Map
- Map<String, Object> result = new HashMap<String, Object>();
+ Map<String, Object> result = new HashMap<>();
result.put("workEffortIds", workEffortIds);
result.put("viewIndex", Integer.valueOf(viewIndex));
Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java?rev=1818442&r1=1818441&r2=1818442&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java Sat Dec 16 17:44:09 2017
@@ -68,7 +68,7 @@ public class WorkEffortSearchSession {
public static void addConstraint(WorkEffortSearchConstraint workEffortSearchConstraint, HttpSession session) {
WorkEffortSearchOptions workEffortSearchOptions = getWorkEffortSearchOptions(session);
if (workEffortSearchOptions.constraintList == null) {
- workEffortSearchOptions.constraintList = new LinkedList<WorkEffortSearch.WorkEffortSearchConstraint>();
+ workEffortSearchOptions.constraintList = new LinkedList<>();
}
if (!workEffortSearchOptions.constraintList.contains(workEffortSearchConstraint)) {
workEffortSearchOptions.constraintList.add(workEffortSearchConstraint);
@@ -131,12 +131,14 @@ public class WorkEffortSearchSession {
public List<String> searchGetConstraintStrings(boolean detailed, Delegator delegator, Locale locale) {
List<WorkEffortSearchConstraint> workEffortSearchConstraintList = this.getConstraintList();
- List<String> constraintStrings = new LinkedList<String>();
+ List<String> constraintStrings = new LinkedList<>();
if (workEffortSearchConstraintList == null) {
return constraintStrings;
}
for (WorkEffortSearchConstraint workEffortSearchConstraint: workEffortSearchConstraintList) {
- if (workEffortSearchConstraint == null) continue;
+ if (workEffortSearchConstraint == null) {
+ continue;
+ }
String constraintString = workEffortSearchConstraint.prettyPrintConstraint(delegator, detailed, locale);
if (UtilValidate.isNotEmpty(constraintString)) {
constraintStrings.add(constraintString);
@@ -161,9 +163,8 @@ public class WorkEffortSearchSession {
Boolean alreadyRun = (Boolean) request.getAttribute("processSearchParametersAlreadyRun");
if (Boolean.TRUE.equals(alreadyRun)) {
return;
- } else {
- request.setAttribute("processSearchParametersAlreadyRun", Boolean.TRUE);
}
+ request.setAttribute("processSearchParametersAlreadyRun", Boolean.TRUE);
HttpSession session = request.getSession();
boolean constraintsChanged = false;
@@ -208,7 +209,7 @@ public class WorkEffortSearchSession {
// add a Product Set to the search
if (UtilValidate.isNotEmpty(parameters.get("productId_1"))) {
- List<String> productSet = new LinkedList<String>();
+ List<String> productSet = new LinkedList<>();
productSet.add((String) parameters.get("productId_1"));
if (UtilValidate.isNotEmpty(parameters.get("productId_2"))) {
productSet.add((String) parameters.get("productId_2"));
@@ -291,7 +292,7 @@ public class WorkEffortSearchSession {
public static List<WorkEffortSearchOptions> getSearchOptionsHistoryList(HttpSession session) {
List<WorkEffortSearchOptions> optionsHistoryList = UtilGenerics.checkList(session.getAttribute("_WORK_EFFORT_SEARCH_OPTIONS_HISTORY_"));
if (optionsHistoryList == null) {
- optionsHistoryList = new LinkedList<WorkEffortSearchSession.WorkEffortSearchOptions>();
+ optionsHistoryList = new LinkedList<>();
session.setAttribute("_WORK_EFFORT_SEARCH_OPTIONS_HISTORY_", optionsHistoryList);
}
return optionsHistoryList;
Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java?rev=1818442&r1=1818441&r2=1818442&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java Sat Dec 16 17:44:09 2017
@@ -92,14 +92,14 @@ public class WorkEffortServices {
validWorkEfforts = EntityQuery.use(delegator).from("WorkEffortAndPartyAssign").where(ecl).orderBy("estimatedStartDate", "priority").filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logWarning(e, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"WorkEffortNotFound", UtilMisc.toMap("errorString", e.toString()), locale));
}
}
- Map<String, Object> result = new HashMap<String, Object>();
+ Map<String, Object> result = new HashMap<>();
if (validWorkEfforts == null) {
- validWorkEfforts = new LinkedList<GenericValue>();
+ validWorkEfforts = new LinkedList<>();
}
result.put("events", validWorkEfforts);
return result;
@@ -113,7 +113,7 @@ public class WorkEffortServices {
List<GenericValue> validWorkEfforts = null;
try {
- List<EntityExpr> conditionList = new LinkedList<EntityExpr>();
+ List<EntityExpr> conditionList = new LinkedList<>();
conditionList.add(EntityCondition.makeCondition("roleTypeId", EntityOperator.EQUALS, roleTypeId));
conditionList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "EVENT"));
conditionList.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_DECLINED"));
@@ -125,13 +125,13 @@ public class WorkEffortServices {
validWorkEfforts = EntityQuery.use(delegator).from("WorkEffortAndPartyAssign").where(ecl).orderBy("estimatedStartDate", "priority").filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logWarning(e, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"WorkEffortNotFound", UtilMisc.toMap("errorString", e.toString()), locale));
}
- Map<String, Object> result = new HashMap<String, Object>();
+ Map<String, Object> result = new HashMap<>();
if (validWorkEfforts == null) {
- validWorkEfforts = new LinkedList<GenericValue>();
+ validWorkEfforts = new LinkedList<>();
}
result.put("events", validWorkEfforts);
return result;
@@ -166,13 +166,15 @@ public class WorkEffortServices {
validWorkEfforts.addAll(EntityQuery.use(delegator).from("WorkEffortAndPartyAssign").where(ecl).orderBy("createdDate DESC").filterByDate().queryList());
} catch (GenericEntityException e) {
Debug.logWarning(e, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"WorkEffortNotFound", UtilMisc.toMap("errorString", e.toString()), locale));
}
}
- Map<String, Object> result = new HashMap<String, Object>();
- if (validWorkEfforts == null) validWorkEfforts = new LinkedList<GenericValue>();
+ Map<String, Object> result = new HashMap<>();
+ if (validWorkEfforts == null) {
+ validWorkEfforts = new LinkedList<>();
+ }
validWorkEfforts = WorkEffortWorker.removeDuplicateWorkEfforts(validWorkEfforts);
result.put("tasks", validWorkEfforts);
return result;
@@ -187,7 +189,7 @@ public class WorkEffortServices {
if (userLogin != null && userLogin.get("partyId") != null) {
try {
- List<EntityExpr> constraints = new LinkedList<EntityExpr>();
+ List<EntityExpr> constraints = new LinkedList<>();
constraints.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, userLogin.get("partyId")));
constraints.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "ACTIVITY"));
@@ -203,13 +205,15 @@ public class WorkEffortServices {
validWorkEfforts = EntityQuery.use(delegator).from("WorkEffortAndPartyAssign").where(constraints).orderBy("priority").filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logWarning(e, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"WorkEffortNotFound", UtilMisc.toMap("errorString", e.toString()), locale));
}
}
- Map<String, Object> result = new HashMap<String, Object>();
- if (validWorkEfforts == null) validWorkEfforts = new LinkedList<GenericValue>();
+ Map<String, Object> result = new HashMap<>();
+ if (validWorkEfforts == null) {
+ validWorkEfforts = new LinkedList<>();
+ }
result.put("activities", validWorkEfforts);
return result;
}
@@ -223,7 +227,7 @@ public class WorkEffortServices {
if (userLogin != null && userLogin.get("partyId") != null) {
try {
- List<EntityExpr> constraints = new LinkedList<EntityExpr>();
+ List<EntityExpr> constraints = new LinkedList<>();
constraints.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, userLogin.get("partyId")));
constraints.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "ACTIVITY"));
@@ -239,13 +243,15 @@ public class WorkEffortServices {
roleWorkEfforts = EntityQuery.use(delegator).from("WorkEffortPartyAssignByRole").where(constraints).orderBy("priority").filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logWarning(e, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"WorkEffortNotFound", UtilMisc.toMap("errorString", e.toString()), locale));
}
}
- Map<String, Object> result = new HashMap<String, Object>();
- if (roleWorkEfforts == null) roleWorkEfforts = new LinkedList<GenericValue>();
+ Map<String, Object> result = new HashMap<>();
+ if (roleWorkEfforts == null) {
+ roleWorkEfforts = new LinkedList<>();
+ }
result.put("roleActivities", roleWorkEfforts);
return result;
}
@@ -259,7 +265,7 @@ public class WorkEffortServices {
if (userLogin != null && userLogin.get("partyId") != null) {
try {
- List<EntityExpr> constraints = new LinkedList<EntityExpr>();
+ List<EntityExpr> constraints = new LinkedList<>();
constraints.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, userLogin.get("partyId")));
constraints.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "ACTIVITY"));
@@ -275,13 +281,15 @@ public class WorkEffortServices {
groupWorkEfforts = EntityQuery.use(delegator).from("WorkEffortPartyAssignByGroup").where(constraints).orderBy("priority").filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logWarning(e, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"WorkEffortNotFound", UtilMisc.toMap("errorString", e.toString()), locale));
}
}
- Map<String, Object> result = new HashMap<String, Object>();
- if (groupWorkEfforts == null) groupWorkEfforts = new LinkedList<GenericValue>();
+ Map<String, Object> result = new HashMap<>();
+ if (groupWorkEfforts == null) {
+ groupWorkEfforts = new LinkedList<>();
+ }
result.put("groupActivities", groupWorkEfforts);
return result;
}
@@ -290,7 +298,7 @@ public class WorkEffortServices {
Delegator delegator = ctx.getDelegator();
GenericValue userLogin = (GenericValue) context.get("userLogin");
Security security = ctx.getSecurity();
- Map<String, Object> resultMap = new HashMap<String, Object>();
+ Map<String, Object> resultMap = new HashMap<>();
String workEffortId = (String) context.get("workEffortId");
GenericValue workEffort = null;
@@ -344,18 +352,30 @@ public class WorkEffortServices {
}
}
- if (workEffortId != null) resultMap.put("workEffortId", workEffortId);
- if (workEffort != null) resultMap.put("workEffort", workEffort);
- if (canView != null) resultMap.put("canView", canView);
- if (workEffortPartyAssignments != null) resultMap.put("partyAssigns", workEffortPartyAssignments);
- if (tryEntity != null) resultMap.put("tryEntity", tryEntity);
- if (currentStatus != null) resultMap.put("currentStatusItem", currentStatus);
+ if (workEffortId != null) {
+ resultMap.put("workEffortId", workEffortId);
+ }
+ if (workEffort != null) {
+ resultMap.put("workEffort", workEffort);
+ }
+ if (canView != null) {
+ resultMap.put("canView", canView);
+ }
+ if (workEffortPartyAssignments != null) {
+ resultMap.put("partyAssigns", workEffortPartyAssignments);
+ }
+ if (tryEntity != null) {
+ resultMap.put("tryEntity", tryEntity);
+ }
+ if (currentStatus != null) {
+ resultMap.put("currentStatusItem", currentStatus);
+ }
return resultMap;
}
private static TreeMap<DateRange, List<Map<String, Object>>> groupCalendarEntriesByDateRange(DateRange inDateRange, List<Map<String, Object>> calendarEntries) {
- TreeMap<DateRange, List<Map<String, Object>>> calendarEntriesByDateRange = new TreeMap<DateRange, List<Map<String, Object>>>();
- Set<Date> dateBoundaries = new TreeSet<Date>();
+ TreeMap<DateRange, List<Map<String, Object>>> calendarEntriesByDateRange = new TreeMap<>();
+ Set<Date> dateBoundaries = new TreeSet<>();
if (inDateRange != null) {
dateBoundaries.add(inDateRange.start());
dateBoundaries.add(inDateRange.end());
@@ -387,11 +407,11 @@ public class WorkEffortServices {
}
private static List<EntityCondition> getDefaultWorkEffortExprList(String calendarType, Collection<String> partyIds, String workEffortTypeId, List<EntityCondition> cancelledCheckAndList) {
- List<EntityCondition> entityExprList = new LinkedList<EntityCondition>();
+ List<EntityCondition> entityExprList = new LinkedList<>();
if (cancelledCheckAndList != null) {
entityExprList.addAll(cancelledCheckAndList);
}
- List<EntityExpr> typesList = new LinkedList<EntityExpr>();
+ List<EntityExpr> typesList = new LinkedList<>();
if (UtilValidate.isNotEmpty(workEffortTypeId)) {
typesList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, workEffortTypeId));
}
@@ -534,13 +554,13 @@ public class WorkEffortServices {
List<GenericValue> validWorkEfforts = null;
Collection<String> partyIdsToUse = partyIds;
if (partyIdsToUse == null) {
- partyIdsToUse = new HashSet<String>();
+ partyIdsToUse = new HashSet<>();
}
if (UtilValidate.isNotEmpty(partyId)) {
if (partyId.equals(userLogin.getString("partyId")) || security.hasEntityPermission("WORKEFFORTMGR", "_VIEW", userLogin)) {
partyIdsToUse.add(partyId);
} else {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"WorkEffortPartyPermissionError", UtilMisc.toMap("partyId", partyId), locale));
}
} else {
@@ -627,9 +647,9 @@ public class WorkEffortServices {
}
// Split the WorkEffort list into a map with entries for each period, period start is the key
- List<Map<String, Object>> periods = new LinkedList<Map<String,Object>>();
+ List<Map<String, Object>> periods = new LinkedList<>();
if (validWorkEfforts != null) {
- List<DateRange> periodRanges = new LinkedList<DateRange>();
+ List<DateRange> periodRanges = new LinkedList<>();
for (int i = 0; i < numPeriods; i++) {
Timestamp curPeriodStart = UtilDateTime.adjustTimestamp(startStamp, periodType, i, timeZone, locale);
Timestamp curPeriodEnd = UtilDateTime.adjustTimestamp(curPeriodStart, periodType, 1, timeZone, locale);
@@ -638,8 +658,8 @@ public class WorkEffortServices {
}
try {
// Process recurring work efforts
- Set<GenericValue> exclusions = new HashSet<GenericValue>();
- Set<GenericValue> inclusions = new HashSet<GenericValue>();
+ Set<GenericValue> exclusions = new HashSet<>();
+ Set<GenericValue> inclusions = new HashSet<>();
DateRange range = new DateRange(startStamp, endStamp);
Calendar cal = UtilDateTime.toCalendar(startStamp, timeZone, locale);
for (GenericValue workEffort : validWorkEfforts) {
@@ -688,8 +708,8 @@ public class WorkEffortServices {
// For each period in the set we check all work efforts to see if they fall within range
boolean firstEntry = true;
for (DateRange periodRange : periodRanges) {
- List<Map<String, Object>> curWorkEfforts = new LinkedList<Map<String,Object>>();
- Map<String, Object> entry = new HashMap<String, Object>();
+ List<Map<String, Object>> curWorkEfforts = new LinkedList<>();
+ Map<String, Object> entry = new HashMap<>();
for (GenericValue workEffort : validWorkEfforts) {
Timestamp startDate = workEffort.getTimestamp("estimatedStartDate");
if (workEffort.getTimestamp("actualStartDate") != null) {
@@ -699,10 +719,12 @@ public class WorkEffortServices {
if (workEffort.getTimestamp("actualCompletionDate") != null) {
endDate = workEffort.getTimestamp("actualCompletionDate");
}
- if (endDate == null) endDate = startDate;
+ if (endDate == null) {
+ endDate = startDate;
+ }
DateRange weRange = new DateRange(startDate, endDate);
if (periodRange.intersectsRange(weRange)) {
- Map<String, Object> calEntry = new HashMap<String, Object>();
+ Map<String, Object> calEntry = new HashMap<>();
calEntry.put("workEffort", workEffort);
long length = ((weRange.end().after(endStamp) ? endStamp.getTime() : weRange.end().getTime()) - (weRange.start().before(startStamp) ? startStamp.getTime() : weRange.start().getTime()));
int periodSpan = (int) Math.ceil((double) length / periodLen);
@@ -734,7 +756,7 @@ public class WorkEffortServices {
periods.add(entry);
}
}
- Map<String, Object> result = new HashMap<String, Object>();
+ Map<String, Object> result = new HashMap<>();
result.put("periods", periods);
result.put("maxConcurrentEntries", Integer.valueOf(maxConcurrentEntries));
return result;
@@ -746,14 +768,14 @@ public class WorkEffortServices {
String facilityId = (String) context.get("facilityId"); // optional
Locale locale = (Locale) context.get("locale");
- Map<String, Map<String, Object>> summaryInByFacility = new HashMap<String, Map<String,Object>>();
- Map<String, Map<String, Object>> summaryOutByFacility = new HashMap<String, Map<String,Object>>();
+ Map<String, Map<String, Object>> summaryInByFacility = new HashMap<>();
+ Map<String, Map<String, Object>> summaryOutByFacility = new HashMap<>();
try {
//
// Information about the running production runs that are going
// to produce units of productId by facility.
//
- List<EntityCondition> findIncomingProductionRunsConds = new LinkedList<EntityCondition>();
+ List<EntityCondition> findIncomingProductionRunsConds = new LinkedList<>();
findIncomingProductionRunsConds.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId));
findIncomingProductionRunsConds.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "WEGS_CREATED"));
@@ -762,7 +784,7 @@ public class WorkEffortServices {
findIncomingProductionRunsConds.add(EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId));
}
- List<EntityCondition> findIncomingProductionRunsStatusConds = new LinkedList<EntityCondition>();
+ List<EntityCondition> findIncomingProductionRunsStatusConds = new LinkedList<>();
findIncomingProductionRunsStatusConds.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "PRUN_CREATED"));
findIncomingProductionRunsStatusConds.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "PRUN_SCHEDULED"));
findIncomingProductionRunsStatusConds.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "PRUN_DOC_PRINTED"));
@@ -796,7 +818,7 @@ public class WorkEffortServices {
Map<String, Object> quantitySummary = UtilGenerics.checkMap(summaryInByFacility.get(weFacilityId));
if (quantitySummary == null) {
- quantitySummary = new HashMap<String, Object>();
+ quantitySummary = new HashMap<>();
quantitySummary.put("facilityId", weFacilityId);
summaryInByFacility.put(weFacilityId, quantitySummary);
}
@@ -809,7 +831,7 @@ public class WorkEffortServices {
List<GenericValue> incomingProductionRunList = UtilGenerics.checkList(quantitySummary.get("incomingProductionRunList"));
if (incomingProductionRunList == null) {
- incomingProductionRunList = new LinkedList<GenericValue>();
+ incomingProductionRunList = new LinkedList<>();
quantitySummary.put("incomingProductionRunList", incomingProductionRunList);
}
incomingProductionRunList.add(incomingProductionRun);
@@ -818,7 +840,7 @@ public class WorkEffortServices {
// Information about the running production runs that are going
// to consume units of productId by facility.
//
- List<EntityCondition> findOutgoingProductionRunsConds = new LinkedList<EntityCondition>();
+ List<EntityCondition> findOutgoingProductionRunsConds = new LinkedList<>();
findOutgoingProductionRunsConds.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId));
findOutgoingProductionRunsConds.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "WEGS_CREATED"));
@@ -827,7 +849,7 @@ public class WorkEffortServices {
findOutgoingProductionRunsConds.add(EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId));
}
- List<EntityCondition> findOutgoingProductionRunsStatusConds = new LinkedList<EntityCondition>();
+ List<EntityCondition> findOutgoingProductionRunsStatusConds = new LinkedList<>();
findOutgoingProductionRunsStatusConds.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "PRUN_CREATED"));
findOutgoingProductionRunsStatusConds.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "PRUN_SCHEDULED"));
findOutgoingProductionRunsStatusConds.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "PRUN_DOC_PRINTED"));
@@ -844,7 +866,7 @@ public class WorkEffortServices {
Map<String, Object> quantitySummary = UtilGenerics.checkMap(summaryOutByFacility.get(weFacilityId));
if (quantitySummary == null) {
- quantitySummary = new HashMap<String, Object>();
+ quantitySummary = new HashMap<>();
quantitySummary.put("facilityId", weFacilityId);
summaryOutByFacility.put(weFacilityId, quantitySummary);
}
@@ -857,14 +879,14 @@ public class WorkEffortServices {
List<GenericValue> outgoingProductionRunList = UtilGenerics.checkList(quantitySummary.get("outgoingProductionRunList"));
if (outgoingProductionRunList == null) {
- outgoingProductionRunList = new LinkedList<GenericValue>();
+ outgoingProductionRunList = new LinkedList<>();
quantitySummary.put("outgoingProductionRunList", outgoingProductionRunList);
}
outgoingProductionRunList.add(outgoingProductionRun);
}
} catch (GenericEntityException gee) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"WorkEffortManufacturingError", UtilMisc.toMap("productId", productId, "errorString", gee.getMessage()), locale));
}
Map<String, Object> resultMap = ServiceUtil.returnSuccess();
@@ -886,11 +908,11 @@ public class WorkEffortServices {
List<GenericValue> eventReminders = null;
try {
eventReminders = EntityQuery.use(delegator).from("WorkEffortEventReminder")
- .where(EntityCondition.makeCondition(UtilMisc.<EntityCondition>toList(EntityCondition.makeCondition("reminderDateTime", EntityOperator.EQUALS, null),
+ .where(EntityCondition.makeCondition(UtilMisc.<EntityCondition>toList(EntityCondition.makeCondition("reminderDateTime", EntityOperator.EQUALS, null),
EntityCondition.makeCondition("reminderDateTime", EntityOperator.LESS_THAN_EQUAL_TO, now)), EntityOperator.OR))
.queryList();
} catch (GenericEntityException e) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"WorkEffortEventRemindersRetrivingError", UtilMisc.toMap("errorString", e), localePar));
}
for (GenericValue reminder : eventReminders) {
@@ -1055,8 +1077,8 @@ public class WorkEffortServices {
List<GenericValue> resultList = null;
try (EntityListIterator eli = (EntityListIterator) context.get("workEffortIterator")) {
if (eli != null) {
- Set<String> keys = new HashSet<String>();
- resultList = new LinkedList<GenericValue>();
+ Set<String> keys = new HashSet<>();
+ resultList = new LinkedList<>();
GenericValue workEffort = eli.next();
while (workEffort != null) {
String workEffortId = workEffort.getString("workEffortId");
Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortWorker.java?rev=1818442&r1=1818441&r2=1818442&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortWorker.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortWorker.java Sat Dec 16 17:44:09 2017
@@ -51,13 +51,13 @@ public final class WorkEffortWorker {
right = "workEffortIdTo";
}
- List<GenericValue> workEfforts = new LinkedList<GenericValue>();
+ List<GenericValue> workEfforts = new LinkedList<>();
try {
List<GenericValue> childWEAssocsLevelFirst = EntityQuery.use(delegator).from("WorkEffortAssoc").where(left, workEffortId, "workEffortAssocTypeId", workEffortAssocTypeId).cache(true).queryList();
for (GenericValue childWEAssocLevelFirst : childWEAssocsLevelFirst) {
List<GenericValue> childWEAssocsLevelNext = EntityQuery.use(delegator).from("WorkEffortAssoc").where(left, childWEAssocLevelFirst.get(right), "workEffortAssocTypeId", workEffortAssocTypeId).cache(true).queryList();
while (UtilValidate.isNotEmpty(childWEAssocsLevelNext)) {
- List<GenericValue> tempWorkEffortList = new LinkedList<GenericValue>();
+ List<GenericValue> tempWorkEffortList = new LinkedList<>();
for (GenericValue childWEAssocLevelNext : childWEAssocsLevelNext) {
List<GenericValue> childWEAssocsLevelNth = EntityQuery.use(delegator).from("WorkEffortAssoc").where(left, childWEAssocLevelNext.get(right), "workEffortAssocTypeId", workEffortAssocTypeId).cache(true).queryList();
if (UtilValidate.isNotEmpty(childWEAssocsLevelNth)) {
@@ -76,8 +76,8 @@ public final class WorkEffortWorker {
}
public static List<GenericValue> removeDuplicateWorkEfforts(List<GenericValue> workEfforts) {
- Set<String> keys = new HashSet<String>();
- Set<GenericValue> exclusions = new HashSet<GenericValue>();
+ Set<String> keys = new HashSet<>();
+ Set<GenericValue> exclusions = new HashSet<>();
for (GenericValue workEffort : workEfforts) {
String workEffortId = workEffort.getString("workEffortId");
if (keys.contains(workEffortId)) {