List of usage examples for java.lang Integer equals
public boolean equals(Object obj)
From source file:com.aurel.track.admin.user.person.PersonConfigBL.java
/** * Whether the number of a user category (all, full, gantt) exceeded the number allowed in license * @param selectedPersonIDList/*from ww w . j a v a2 s. com*/ * @param locale * @param activateDisabledUsers * @return */ public static String usersExceeded(List<Integer> selectedPersonIDList, Locale locale, Integer newUserLevel, boolean activateDisabledUsers) { ApplicationBean appBean = ApplicationBean.getInstance(); //max allowed values int maxNumberOfFullUsers = appBean.getMaxNumberOfFullUsers(); int maxNumberOfEasyUsers = appBean.getMaxNumberOfLimitedUsers(); //actual values int actualFullActive = appBean.getFullActive(); int actualEasyActive = appBean.getLimitedActive(); String exceedAllActiveMessage = activeUsersExceeded(actualFullActive + actualEasyActive, selectedPersonIDList, maxNumberOfFullUsers + maxNumberOfEasyUsers, locale, newUserLevel, false, activateDisabledUsers); if (exceedAllActiveMessage != null) { LOGGER.info("Total number of active users exceeded"); return exceedAllActiveMessage; } String exceedFullActiveMessage = activeUsersExceeded(actualFullActive, selectedPersonIDList, maxNumberOfFullUsers, locale, newUserLevel, true, activateDisabledUsers); if (exceedFullActiveMessage != null) { LOGGER.info("Total number of active full users exceeded"); return exceedFullActiveMessage; } if (newUserLevel != null && newUserLevel.equals(TPersonBean.USERLEVEL.CLIENT)) { LOGGER.info("Remove licensed features for client users"); UserFeatureBL.deleteFeaturesForPersons(selectedPersonIDList); } if (activateDisabledUsers) { List<LicensedFeature> licensedFeatures = UserFeatureBL.getLicensedFeatures(); if (licensedFeatures != null) { for (LicensedFeature licensedFeature : licensedFeatures) { String featureExceeded = UserFeatureBL.featureExceeded(selectedPersonIDList, licensedFeature.getNumberOfUsers(), licensedFeature.getFeatureId(), licensedFeature.getFeatureName(), locale); if (featureExceeded != null) { return featureExceeded; } } } } return null; }
From source file:com.almende.eve.agent.google.GoogleCalendarAgent.java
/** * Get a single event by id.//from ww w. ja v a 2s . co m * * @param eventId * Id of the event * @param calendarId * Optional calendar id. the primary calendar is used by default * @return the event * @throws Exception * the exception */ @Override public ObjectNode getEvent(@Name("eventId") final String eventId, @Optional @Name("calendarId") String calendarId) throws Exception { // initialize optional parameters if (calendarId == null) { calendarId = getState().get("email", String.class); } // built url final String url = CALENDAR_URI + calendarId + "/events/" + eventId; // perform GET request final Map<String, String> headers = getAuthorizationHeaders(); final String resp = HttpUtil.get(url, headers); final ObjectMapper mapper = JOM.getInstance(); final ObjectNode event = mapper.readValue(resp, ObjectNode.class); // convert from Google to Eve event toEveEvent(event); // check for errors if (event.has("error")) { final ObjectNode error = (ObjectNode) event.get("error"); final Integer code = error.has("code") ? error.get("code").asInt() : null; if (code != null && (code.equals(404) || code.equals(410))) { throw new JSONRPCException(CODE.NOT_FOUND); } throw new JSONRPCException(error); } // check if canceled. If so, return null // TODO: be able to retrieve canceled events? if (event.has("status") && event.get("status").asText().equals("cancelled")) { throw new JSONRPCException(CODE.NOT_FOUND); } return event; }
From source file:com.aurel.track.admin.customize.category.filter.execute.SavedFilterExecuteAction.java
/** * Replace the specified parameters from the submitted parameters and then execute the filter * The filter can be an encoded query a saved query (directly executed or after a possible instant modification) * @return/*from w ww. j a v a 2 s . c o m*/ */ public String replaceSubmittedParameters() { FilterUpperTO originalFilterUpperTO = null; QNode rootNodeOriginal = null; if (query != null && query.length() > 0) { //parameters for encoded query URL String linkReport = ReportQueryBL.b(query); Map<String, String> queryEncodedMap = ReportQueryBL.decodeMapFromUrl(linkReport); String queryIDStr = queryEncodedMap.get("queryID"); Integer filterID = null; if (queryIDStr != null) { filterID = Integer.decode(queryIDStr); if (filterID != null) { TQueryRepositoryBean queryRepositoryBean = (TQueryRepositoryBean) TreeFilterFacade.getInstance() .getByKey(filterID); if (queryRepositoryBean != null) { String filterExpression = FilterBL.getFilterExpression(queryRepositoryBean); HttpServletRequest request = null; QNode extendedRootNode = TreeFilterReader.getInstance().readQueryTree(filterExpression); originalFilterUpperTO = FilterUpperFromQNodeTransformer .getFilterSelectsFromTree(extendedRootNode, true, true, personBean, locale, true); rootNodeOriginal = TreeFilterLoaderBL.getOriginalTree(extendedRootNode); if (FilterSelectsParametersUtil.containsParameter(originalFilterUpperTO)) { //set the request request = ServletActionContext.getRequest(); //replace the corresponding query parameters with corresponding request parameters try { FilterSelectsParametersUtil.replaceFilterSelectsParameters(originalFilterUpperTO, request, personBean, locale, false); } catch (NotExistingBeanException e) { } } } } } } else { if (filterID == null) { //from an eventually "instantly" modified filter (put into the session in the FilterAction) originalFilterUpperTO = (FilterUpperTO) session.get(FILTER_UPPER_WITH_PARAM); rootNodeOriginal = (QNode) session.get(TREE_WITH_PARAM); } else { //directly executed (not opened for edit) FilterFacade filterFacade = TreeFilterFacade.getInstance(); TQueryRepositoryBean queryRepositoryBean = (TQueryRepositoryBean) filterFacade.getByKey(filterID); if (queryRepositoryBean != null) { String filterExpression = FilterBL.getFilterExpression(queryRepositoryBean); QNode extendedRootNode = TreeFilterReader.getInstance().readQueryTree(filterExpression); originalFilterUpperTO = FilterUpperFromQNodeTransformer .getFilterSelectsFromTree(extendedRootNode, true, true, personBean, locale, true); rootNodeOriginal = TreeFilterLoaderBL.getOriginalTree(extendedRootNode); } } } if (originalFilterUpperTO == null && rootNodeOriginal == null) { //no parameters at all. Should never happen return null; } if (originalFilterUpperTO == null) { //in the original upper part was nothing selected. originalFilterUpperTO = new FilterUpperTO(); } if (filterUpperTO == null) { //nothing was submitted to parameterized selects (or none of the selects were parameterized) filterUpperTO = new FilterUpperTO(); } //1. replace the upper select parameters FilterUpperTO replacedFilterSelectsTO = FilterSelectsParametersUtil.replaceParameters(originalFilterUpperTO, filterUpperTO, locale); //2. replace the matchers and values in FieldExpressionSimple fields List<FieldExpressionSimpleTO> originalFieldExpressionSimpleList = originalFilterUpperTO .getFieldExpressionSimpleList(); List<FieldExpressionSimpleTO> parameterizedFieldExpressionSimpleList = FilterSubmitHandler .createFieldExpressionSimpleListAfterSubmit(simpleMatcherRelationMap, simpleDisplayValueMap, locale); Map<Integer, FieldExpressionSimpleTO> fieldBasedFieldExpressionSimpleMap = new HashMap<Integer, FieldExpressionSimpleTO>(); for (FieldExpressionSimpleTO fieldExpressionSimpleTO : parameterizedFieldExpressionSimpleList) { Integer fieldID = fieldExpressionSimpleTO.getField(); fieldBasedFieldExpressionSimpleMap.put(fieldID, fieldExpressionSimpleTO); } if (originalFieldExpressionSimpleList != null) { for (FieldExpressionSimpleTO fieldExpressionSimpleTO : originalFieldExpressionSimpleList) { Integer fieldID = fieldExpressionSimpleTO.getField(); Integer matcherID = fieldExpressionSimpleTO.getSelectedMatcher(); if (fieldID != null && matcherID != null && matcherID.equals(MatcherContext.PARAMETER)) { FieldExpressionSimpleTO parameterFieldExpressionSimpleTO = fieldBasedFieldExpressionSimpleMap .get(fieldID); if (parameterFieldExpressionSimpleTO != null) { fieldExpressionSimpleTO .setSelectedMatcher(parameterFieldExpressionSimpleTO.getSelectedMatcher()); fieldExpressionSimpleTO.setValue(parameterFieldExpressionSimpleTO.getValue()); } } } } //3. replace the matchers and values in the tree part List<FieldExpressionSimpleTO> treePartFieldExpressionSimpleList = FilterSubmitHandler .createFieldExpressionSimpleListAfterSubmit(fieldMap, inTreeMatcherRelationMap, inTreeDisplayValueMap, locale); QNode replacedTree = QNodeParametersUtil.replaceParameters(rootNodeOriginal, treePartFieldExpressionSimpleList); String filterExpression = null; try { QNode extendedNode = TreeFilterSaverBL.createQNodeWithQueryListsTO(replacedTree, replacedFilterSelectsTO, null); filterExpression = TreeFilterWriter.getInstance().toXML(extendedNode); } catch (Exception e) { String errorKey = e.getMessage(); String errorMessage = LocalizeUtil.getLocalizedTextFromApplicationResources(errorKey, locale); LOGGER.warn("Transforming the instant query to expression failed with " + errorMessage); } QueryContext queryContext = new QueryContext(); //although a parameterized filter is a saved filter, it is saved in QueryContext as INSTANT_REPORT_FILTER //independently whether it was executed from edit mode (possibly "instantly" modified) //or directly because the parameters have to be replaced anyway and then the resulting expression should be saved in QueryContext queryContext.setQueryType(ItemNavigatorBL.QUERY_TYPE.INSTANT); queryContext.setQueryID(TQueryRepositoryBean.QUERY_PURPOSE.TREE_FILTER); queryContext.setFilterExpression(filterExpression); LastExecutedBL.storeLastExecutedQuery(personBean.getObjectID(), queryContext); if (ajax) { JSONUtility.encodeJSONSuccess(servletResponse); return null; } else { return "itemNavigator"; } }
From source file:com.heliumv.api.worktime.WorktimeApi.java
private boolean isValidOrderPositionId(Integer orderId, Integer positionId) throws NamingException { AuftragpositionDto auftragPositionDto = auftragpositionCall .auftragpositionFindByPrimaryKeyOhneExc(positionId); if (auftragPositionDto == null) return false; return orderId.equals(auftragPositionDto.getBelegIId()); }
From source file:org.openmrs.web.dwr.DWRConceptService.java
/** * Find a list of {@link ConceptListItem} or {@link ConceptDrugListItem}s that are answers to * the given question. The given question is determined by the given <code>conceptId</code> * /*w ww . j a v a2 s . c o m*/ * @param text the text to search for within the answers * @param conceptId the conceptId of the question concept * @param includeVoided (this argument is ignored now. searching for voided answers is not * logical) * @param includeDrugConcepts if true, drug concepts are searched too * @return list of {@link ConceptListItem} or {@link ConceptDrugListItem} answers that match the * query * @throws Exception if given conceptId is not found * @should not fail if the specified concept has no answers (regression test for TRUNK-2807) * @should search for concept answers in all search locales * @should not return duplicates */ public List<Object> findConceptAnswers(String text, Integer conceptId, boolean includeVoided, boolean includeDrugConcepts) throws Exception { if (includeVoided) { throw new APIException("You should not include voideds in the search."); } ConceptService cs = Context.getConceptService(); Concept concept = cs.getConcept(conceptId); if (concept == null) { throw new Exception("Unable to find a concept with id: " + conceptId); } List<ConceptSearchResult> searchResults = new ArrayList<ConceptSearchResult>(); List<Locale> locales = Context.getAdministrationService().getSearchLocales(); for (Locale lc : locales) { List<ConceptSearchResult> results = cs.findConceptAnswers(text, lc, concept); if (results != null) { searchResults.addAll(results); } } List<Drug> drugAnswers = new ArrayList<Drug>(); for (ConceptAnswer conceptAnswer : concept.getAnswers(false)) { if (conceptAnswer.getAnswerDrug() != null) { drugAnswers.add(conceptAnswer.getAnswerDrug()); } } List<Object> items = new ArrayList<Object>(); Set<Integer> uniqueItems = new HashSet<Integer>(); for (ConceptSearchResult searchResult : searchResults) { if (!uniqueItems.add(searchResult.getConcept().getConceptId())) { continue; //Skip already added items } items.add(new ConceptListItem(searchResult)); // add drugs for concept if desired if (includeDrugConcepts) { Integer classId = searchResult.getConcept().getConceptClass().getConceptClassId(); if (classId.equals(OpenmrsConstants.CONCEPT_CLASS_DRUG)) { for (Drug d : cs.getDrugsByConcept(searchResult.getConcept())) { if (drugAnswers.contains(d)) { items.add(new ConceptDrugListItem(d, Context.getLocale())); } } } } } return items; }
From source file:ch.puzzle.itc.mobiliar.presentation.deploy.CreateDeploymentView.java
public void setSelectedApplicationServerGroup(Integer selectedGroupId) { deploymentDate = null;/*ww w . j av a 2 s . c om*/ ResourceGroupEntity newSelectedGroup = null; for (ResourceGroupEntity group : applicationServerGroups) { if (group.getId().equals(selectedGroupId)) { newSelectedGroup = group; break; } } if (newSelectedGroup != null) { boolean hasChanged = selectedApplicationServerGroup == null || !selectedGroupId.equals(selectedApplicationServerGroup.getId()); if (hasChanged) { // load all relations of all resources so we can work with them on the gui selectedApplicationServerGroup = controller .getResourceGroupWithResourceRelations(newSelectedGroup.getId()); loadReleasesForAs(); selectedRelease = getDefaultRelease(); loadApplicationsForSelecedAppServer(); } } else { selectedApplicationServerGroup = null; selectedAppServer = null; appsWithVersion = new LinkedList<>(); } }
From source file:com.bizintelapps.bugtracker.service.impl.ReportServiceImpl.java
@Override public ProjectReportDto getCurrentProjectReport(Integer project, String requestedBy) { Users requestedUser = usersDao.findByUsername(requestedBy); Integer org = null;/*w w w .ja va 2s . c o m*/ ProjectReport list = null; ProjectReportDto dto = null; Calendar c = Calendar.getInstance(); int month = c.get(Calendar.MONTH); int year = c.get(Calendar.YEAR); if (project == null || project.equals(0)) { org = requestedUser.getOrganization().getId(); list = projectReportDao.findByOrganizationMonthAndYear(org, month, year); } else { list = projectReportDao.findByProjectMonthAndYear(project, month, year); } // copy for display dto = projectReportDtoA.copyForDisplay(list); return dto; }
From source file:com.redhat.persistence.oql.EquiSet.java
boolean add(List equal) { Integer to = null; List added = null;/* w w w .java 2s.co m*/ int addedidx = -1; m_from.clear(); for (int i = 0; i < equal.size(); i++) { Object o = equal.get(i); Integer idx = (Integer) m_nodes.get(o); if (idx == null) { if (added == null) { addedidx = allocatePartition(); added = getPartition(addedidx); } added.add(o); } else if (to == null) { to = idx; } else if (to.equals(idx)) { // do nothing } else { List top = getPartition(to); List fromp = getPartition(idx); if (fromp.size() > top.size()) { m_from.add(to); to = idx; } else { m_from.add(idx); } } } if (to == null) { if (added == null) { return false; } else { partitionAll(added, new Integer(addedidx)); return true; } } List top = getPartition(to); boolean modified = false; if (added != null) { if (added.size() > top.size()) { m_from.add(to); to = new Integer(addedidx); top = added; partitionAll(added, to); modified = true; } else { m_from.add(new Integer(addedidx)); } } for (int i = 0; i < m_from.size(); i++) { Integer idx = (Integer) m_from.get(i); List from = getPartition(idx); for (int j = 0; j < from.size(); j++) { Object o = from.get(j); top.add(o); m_nodes.put(o, to); } from.clear(); m_free.add(idx); modified = true; } return modified; }
From source file:com.eryansky.service.base.ResourceManager.java
/** * ResourceTreeNode//from w w w. j ava 2 s . c o m * @param resource ? * @param resourceType ? * @param isCascade ?? * @return * @throws DaoException * @throws SystemException * @throws ServiceException */ private TreeNode resourceToTreeNode(Resource resource, Integer resourceType, boolean isCascade) throws DaoException, SystemException, ServiceException { if (resourceType != null) { if (!resourceType.equals(resource.getType())) { return null; } } TreeNode treeNode = new TreeNode(resource.getId().toString(), resource.getName(), resource.getIconCls()); // url Map<String, Object> attributes = Maps.newHashMap(); attributes.put("url", resource.getUrl()); attributes.put("markUrl", resource.getMarkUrl()); attributes.put("code", resource.getCode()); attributes.put("type", resource.getType()); treeNode.setAttributes(attributes); if (isCascade) { List<TreeNode> childrenTreeNodes = Lists.newArrayList(); for (Resource subResource : resource.getSubResources()) { TreeNode node = resourceToTreeNode(subResource, resourceType, isCascade); if (node != null) { childrenTreeNodes.add(node); } } treeNode.setChildren(childrenTreeNodes); } return treeNode; }
From source file:net.groupbuy.template.directive.PaginationDirective.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { String pattern = FreemarkerUtils.getParameter(PATTERN_PARAMETER_NAME, String.class, params); Integer pageNumber = FreemarkerUtils.getParameter(PAGE_NUMBER_PARAMETER_NAME, Integer.class, params); Integer totalPages = FreemarkerUtils.getParameter(TOTAL_PAGES_PARAMETER_NAME, Integer.class, params); Integer segmentCount = FreemarkerUtils.getParameter(SEGMENT_COUNT_PARAMETER_NAME, Integer.class, params); if (pageNumber == null || pageNumber < 1) { pageNumber = 1;/*from w w w . ja v a2 s . c om*/ } if (totalPages == null || totalPages < 1) { totalPages = 1; } if (segmentCount == null || segmentCount < 1) { segmentCount = 5; } boolean hasPrevious = pageNumber > 1; boolean hasNext = pageNumber < totalPages; boolean isFirst = pageNumber == 1; boolean isLast = pageNumber.equals(totalPages); int previousPageNumber = pageNumber - 1; int nextPageNumber = pageNumber + 1; int firstPageNumber = 1; int lastPageNumber = totalPages; int startSegmentPageNumber = pageNumber - (int) Math.floor((segmentCount - 1) / 2D); int endSegmentPageNumber = pageNumber + (int) Math.ceil((segmentCount - 1) / 2D); if (startSegmentPageNumber < 1) { startSegmentPageNumber = 1; } if (endSegmentPageNumber > totalPages) { endSegmentPageNumber = totalPages; } List<Integer> segment = new ArrayList<Integer>(); for (int i = startSegmentPageNumber; i <= endSegmentPageNumber; i++) { segment.add(i); } Map<String, Object> variables = new HashMap<String, Object>(); variables.put(PATTERN_VARIABLE_NAME, pattern); variables.put(PAGE_NUMBER_VARIABLE_NAME, pageNumber); variables.put(PAGE_COUNT_VARIABLE_NAME, totalPages); variables.put(SEGMENT_COUNT_VARIABLE_NAME, segmentCount); variables.put(HAS_PREVIOUS_VARIABLE_NAME, hasPrevious); variables.put(HAS_NEXT_VARIABLE_NAME, hasNext); variables.put(IS_FIRST_VARIABLE_NAME, isFirst); variables.put(IS_LAST_VARIABLE_NAME, isLast); variables.put(PREVIOUS_PAGE_NUMBER_VARIABLE_NAME, previousPageNumber); variables.put(NEXT_PAGE_NUMBER_VARIABLE_NAME, nextPageNumber); variables.put(FIRST_PAGE_NUMBER_VARIABLE_NAME, firstPageNumber); variables.put(LAST_PAGE_NUMBER_VARIABLE_NAME, lastPageNumber); variables.put(SEGMENT_VARIABLE_NAME, segment); setLocalVariables(variables, env, body); }