List of usage examples for java.lang Boolean equals
public boolean equals(Object obj)
From source file:no.imr.stox.functions.acoustic.PgNapesIO.java
public static void export(String cruise, String country, String callSignal, String path, String fileName, List<DistanceBO> distances, String species, Double intDist, Double pchThick) { // Atle: implement! Integer acoCat = PgNapesEchoConvert.getAcoCatFromPgNapesSpecies(species); BufferedWriter bWriter1 = null; BufferedWriter bWriter2 = null; try {/*from www. j a v a2 s . c om*/ String fil1 = path + "/" + fileName + "_Acoustic.txt"; String fil2 = path + "/" + fileName + "_AcousticValues.txt"; bWriter1 = new BufferedWriter(new FileWriter(fil1)); bWriter2 = new BufferedWriter(new FileWriter(fil2)); bWriter1.write("Country" + "" + "\t" + "Vessel" + "" + "\t" + "Cruise" + "" + "\t" + "Log" + "" + "\t"); bWriter1.write("Year" + "" + "\t" + "Month" + "" + "\t" + "Day" + "" + "\t" + "Hour" + "" + "\t"); bWriter1.write("Min" + "" + "\t" + "AcLat" + "" + "\t" + "AcLon" + "" + "\t" + "Logint" + "" + "\t"); bWriter1.write("Frequency" + "" + "\t" + "Sv_threshold"); bWriter1.newLine(); bWriter2.write("Country" + "" + "\t" + "Vessel" + "" + "\t" + "Cruise" + "" + "\t" + "Log" + "" + "\t"); bWriter2.write("Year" + "" + "\t" + "Month" + "" + "\t" + "Day" + "" + "\t" + "Species" + "" + "\t"); bWriter2.write("ChUppDepth" + "" + "\t" + "ChLowDepth" + "" + "\t" + "SA"); bWriter2.newLine(); Boolean isEnd = true; //Vertical Resolution/new channel thickness from filter Double totintdist = 0.0; Integer countdist = 0; Double sa50ch[] = new Double[1001]; //sa pr intdist Double saout[] = new Double[1001]; //sa accumulated over 5 nm. Output to files for (int g = 0; g < sa50ch.length; g++) { sa50ch[g] = 0.0; saout[g] = 0.0; } String hout1[] = new String[14]; // Sheet1: header info from first intdist in 5 nm dist for (int h = 0; h < hout1.length; h++) { hout1[h] = null; } String hout2[] = new String[8]; // Sheet2: header info from first intdist in 5 nm dist for (int h = 0; h < hout2.length; h++) { hout2[h] = null; } Resolution rr = new Resolution(); //GO THROUGH ALL OBSERVATIONS IN SELECTED DATASETT ONE OBS AT THE TIME Integer nobs = distances.size(); for (int line = 0; line < nobs; line++) { DistanceBO dist = distances.get(line); for (FrequencyBO f : dist.getFrequencies()) { FrequencyBO frequency = f; //PS! What if threshold change within a 5 nm ?? Use first value OK??? String threshold = Double.toString(frequency.getThreshold()); //String helpNumPel = Integer.toString(freq.getNum_pel_ch()); Date d = dist.getStart_time(); String helpymd = IMRdate.formatDate(d, "yyyyMMdd"); String year = helpymd.substring(0, 4); String month = helpymd.substring(4, 6); String day = helpymd.substring(6, 8); String helphms = IMRdate.formatDate(d, "HHmmss"); String hour = helphms.substring(0, 2); String min = helphms.substring(2, 4); // String Log = df.format(dist.getLog_start()/*LogFloor*/); String log = Conversion.formatDoubletoDecimalString(dist.getLog_start().doubleValue(), "0.0"); //Check if this is the end of the integrator distance (using the filter value rr.setIntDist(Math.max(intDist, dist.getIntegrator_dist())); rr.setLog(Conversion.safeStringtoDouble(log)); isEnd = rr.getIsEnd(); String acLat = Conversion.formatDoubletoDecimalString(dist.getLat_start(), "0.000"); String acLon = Conversion.formatDoubletoDecimalString(dist.getLon_start(), "0.000"); Double helppct = dist.getPel_ch_thickness(); Integer helppctR = (int) Math.round(helppct); //Number of ch per 50 meter ch Double vertRes = null; if (pchThick != null && pchThick > dist.getPel_ch_thickness()) { vertRes = pchThick; } else { vertRes = dist.getPel_ch_thickness(); } Double ww = vertRes / helppct; Integer helpnchch = ww.intValue(); //Number of 50 meter channels Integer q = frequency.getNum_pel_ch(); Integer ww1 = frequency.getNum_pel_ch() % helpnchch; Integer ww2 = (frequency.getNum_pel_ch() / helpnchch); Integer helpnch = ww2.intValue(); if (ww1 > 0) { helpnch = helpnch + 1; } if (helpnch > sa50ch[0]) { sa50ch[0] = helpnch.doubleValue(); } // SUM UP P SA VALUES FOR THIS OBSERVATION IN 50 meter CHANNELS List<SABO> salist = frequency.getSa(); for (Integer ch = 1; ch <= frequency.getNum_pel_ch(); ch++) { if (ch <= frequency.getNum_pel_ch()) { //Double saval = 0.0; for (Integer i = 0; i < salist.size(); i++) { //storage.getSaByFrequencyChannelTypeAcousticCategory(freq, "P", f.getId_acoustic_category()); SABO elm = salist.get(i); if (elm.getAcoustic_category() == null || elm.getCh() == null || elm.getCh_type() == null || !elm.getCh().equals(ch) || !elm.getCh_type().equals("P") || !elm.getAcoustic_category().equalsIgnoreCase(acoCat.toString())) { continue; } Double ch50a = (ch * helppctR.doubleValue()) % vertRes; Double ch50b = (ch * helppctR.doubleValue()) / vertRes; Integer ch50c = ch50b.intValue(); if (ch50a > 0) { ch50c = ch50c + 1; } sa50ch[ch50c] = elm.getSa() + sa50ch[ch50c]; sa50ch[1000] = elm.getSa() + sa50ch[1000]; break; } } } //IF START OF A NEW 5 NM DISTANCE KEEP HEADING VALUES if (isEnd.equals(true)) { hout1[0] = country; hout1[1] = callSignal; hout1[2] = cruise; hout1[3] = log; hout1[4] = year; hout1[5] = month; hout1[6] = day; hout1[7] = hour; hout1[8] = min; hout1[9] = acLat; hout1[10] = acLon; //hout1[11] = Logint; hout1[12] = frequency.getFreq().toString(); hout1[13] = threshold; hout2[0] = country; hout2[1] = callSignal; hout2[2] = cruise; hout2[3] = log; hout2[4] = year; hout2[5] = month; hout2[6] = day; hout2[7] = species; } //KEEP SA-VALUES FROM THIS INTEGRATOR DISTANCE if (sa50ch[0] > saout[0]) { saout[0] = sa50ch[0]; } for (int k = 1; k < saout.length; k++) { saout[k] = saout[k] + sa50ch[k]; } //Count number of intdist + totaldist countdist = countdist + 1; totintdist = totintdist + dist.getIntegrator_dist(); boolean okIntDist = false; //Check if distance from previous output distance is not to large due to holes in data: boolean okPrevDist = false; if ((rr.getEndLog() != null) && (rr.getIntDist() != null)) { if ((rr.getLog() - rr.getEndLog()) - 0.05 <= rr.getIntDist()) { okPrevDist = true; } else { okPrevDist = false; } } else { okPrevDist = true; } //Check if sum of distances is correct + check if stoplog minus startlog is equal to sum of distances if (rr.getIntDist() == null) { okIntDist = true; } else { if ((((rr.getIntDist() - 0.05) < totintdist) && (totintdist < (rr.getIntDist() + 0.05))) && okPrevDist) { okIntDist = true; } } //PRINT TO FILES if (okIntDist && isEnd) { for (int k = 1; k < saout.length; k++) { saout[k] = saout[k] / countdist; } //Sheet file 1: hout1[11] = Conversion.formatDoubletoDecimalString(totintdist, "0.0"); for (Integer elm = 0; elm < 14; elm++) { if (hout1[elm] != null) { bWriter1.write(hout1[elm] + "" + "\t"); } else { bWriter1.write(" " + "" + "\t"); } } bWriter1.newLine(); //Sheet file 2: for (Integer elm = 0; elm < saout[0].intValue(); elm++) { for (Integer e = 0; e < 8; e++) { bWriter2.write(hout2[e] + "" + "\t"); } bWriter2.write((elm * vertRes) + "" + "\t"); bWriter2.write(((elm * vertRes) + vertRes) + "" + "\t"); String sa = String.format(Locale.UK, "%11.5f", (saout[elm + 1])); bWriter2.write(sa + "" + "\t"); bWriter2.newLine(); } } else { for (int k = 1; k < sa50ch.length; k++) { sa50ch[k] = 0.0; } } if (isEnd.equals(true)) { for (int g = 0; g < sa50ch.length; g++) { sa50ch[g] = 0.0; saout[g] = 0.0; } //Total sa all channels, this variable is not used, test only sa50ch[1000] = 0.0; //Max number of 50 meter channels in 5 nm distance sa50ch[0] = 0.0; countdist = 0; totintdist = 0.0; } } // Have to look up by frequency here in future. } bWriter1.close(); bWriter2.close(); } catch (IOException ex) { throw new UncheckedIOException(ex); } }
From source file:org.sakaiproject.citation.tool.CitationHelperAction.java
public String buildNewResourcePanelContext(VelocityPortlet portlet, Context context, RunData rundata, SessionState state) {//w w w .ja va 2s . c om logger.debug("buildNewResourcePanelContext()"); context.put("MIMETYPE_JSON", MIMETYPE_JSON); context.put("REQUESTED_MIMETYPE", REQUESTED_MIMETYPE); context.put("xilator", new Validator()); context.put("availability_is_enabled", Boolean.TRUE); context.put("GROUP_ACCESS", AccessMode.GROUPED); context.put("INHERITED_ACCESS", AccessMode.INHERITED); Boolean resourceAdd = (Boolean) state.getAttribute(STATE_RESOURCES_ADD); if (resourceAdd != null && resourceAdd.equals(true)) { context.put("resourceAdd", Boolean.TRUE); context.put(CITATION_ACTION, CREATE_RESOURCE); } else { context.put(CITATION_ACTION, UPDATE_RESOURCE); } // resource-related String resourceId = (String) state.getAttribute(CitationHelper.RESOURCE_ID); String resourceUuid = (String) state.getAttribute(CitationHelper.RESOURCE_UUID); if (resourceId == null || resourceId.trim().equals("")) { if (resourceUuid == null || resourceUuid.trim().equals("")) { // Will be dealt with later by creating new resource when needed } else if (resourceUuid.startsWith("/")) { // UUID and ID may be switched resourceId = resourceUuid; resourceUuid = this.getContentService().getUuid(resourceId); if (resourceUuid != null) { state.setAttribute(CitationHelper.RESOURCE_ID, resourceId); state.setAttribute(CitationHelper.RESOURCE_UUID, resourceUuid); } } else { // see if we can get the resourceId from the UUID resourceId = this.getContentService().resolveUuid(resourceUuid); if (resourceId != null) { state.setAttribute(CitationHelper.RESOURCE_ID, resourceId); } } } else if (resourceUuid == null || resourceUuid.trim().equals("")) { resourceUuid = this.getContentService().getUuid(resourceId); if (resourceUuid != null) { state.setAttribute(CitationHelper.RESOURCE_UUID, resourceUuid); } } if (logger.isDebugEnabled()) { logger.debug("buildNewResourcePanelContext() resourceUuid == " + resourceUuid + " resourceId == " + resourceId); } String citationCollectionId = null; ContentResource resource = null; Map<String, Object> contentProperties = null; if (resourceId == null) { } else { try { resource = getContentService().getResource(resourceId); } catch (IdUnusedException e) { logger.warn("IdUnusedException geting resource in buildNewResourcePanelContext() " + e); } catch (TypeException e) { logger.warn("TypeException geting resource in buildNewResourcePanelContext() " + e); } catch (PermissionException e) { logger.warn("PermissionException geting resource in buildNewResourcePanelContext() " + e); } // String guid = getContentService().getUuid(resourceId); // context.put("RESOURCE_ID", guid); } if (resource == null) { context.put(CITATION_ACTION, CREATE_RESOURCE); ToolSession toolSession = getSessionManager().getCurrentToolSession(); ResourceToolActionPipe pipe = (ResourceToolActionPipe) toolSession .getAttribute(ResourceToolAction.ACTION_PIPE); String contentCollectionId = pipe.getContentEntity().getId(); context.put("contentCollectionId", contentCollectionId); ContentCollection collection; try { collection = getContentService().getCollection(contentCollectionId); contentProperties = this.getProperties(collection, state); } catch (IdUnusedException e) { logger.warn("IdUnusedException geting collection in buildNewResourcePanelContext() " + e); } catch (TypeException e) { logger.warn("TypeException geting collection in buildNewResourcePanelContext() " + e); } catch (PermissionException e) { logger.warn("PermissionException geting collection in buildNewResourcePanelContext() " + e); } } else { ResourceProperties props = resource.getProperties(); contentProperties = this.getProperties(resource, state); context.put("resourceTitle", props.getProperty(ResourceProperties.PROP_DISPLAY_NAME)); context.put("resourceDescription", props.getProperty(ResourceProperties.PROP_DESCRIPTION)); context.put("resourceIntroduction", (props.getProperty(CitationService.PROP_INTRODUCTION) == null ? props.getProperty(ResourceProperties.PROP_DESCRIPTION) : props.getProperty(CitationService.PROP_INTRODUCTION))); context.put("officialInstBackColour", scs.getString("official.institution.background.colour")); context.put("officialInstTextColour", scs.getString("official.institution.text.colour")); //resourceUuid = this.getContentService().getUuid(resourceId); context.put("resourceUuid", resourceUuid); context.put("contentCollectionId", resource.getContainingCollection().getId()); try { citationCollectionId = new String(resource.getContent()); if (citationCollectionId != null) { state.setAttribute(STATE_CITATION_COLLECTION_ID, citationCollectionId); } } catch (ServerOverloadException e) { logger.warn("ServerOverloadException geting props in buildNewResourcePanelContext() " + e); } context.put(CITATION_ACTION, UPDATE_RESOURCE); } if (contentProperties == null) { contentProperties = new HashMap<String, Object>(); } context.put("contentProperties", contentProperties); int collectionSize = 0; CitationCollection citationCollection = getCitationCollection(state, true); // nested sections and nested citations CitationCollectionOrder nestedCollection = getCitationService() .getNestedCollection(citationCollection.getId()); context.put("nestedCollection", nestedCollection); context.put("nestedSectionsSize", nestedCollection.getChildren().size()); // unnested citations CitationCollection unnestedCitationCollection = getCitationService() .getUnnestedCitationCollection(citationCollection.getId()); context.put("unnestedCitationCollection", unnestedCitationCollection); context.put("unnestedCitationCollectionSize", unnestedCitationCollection.size()); // all citations context.put("allCitationCollection", citationCollection); if (citationCollection == null) { logger.warn( "buildAddCitationsPanelContext unable to access citationCollection " + citationCollectionId); int requestStateId = preserveRequestState(state, new String[] { CitationHelper.RESOURCES_REQUEST_PREFIX, CitationHelper.CITATION_PREFIX }); context.put("requestStateId", requestStateId); return TEMPLATE_ERROR; } else { // get the size of the list collectionSize = citationCollection.size(); citationCollectionId = citationCollection.getId(); } context.put("citationCollectionId", citationCollectionId); context.put("collectionSize", new Integer(collectionSize)); context.put("sectionBackgroundColour", scs.getString("official.institution.background.colour")); context.put("sectionTextColour", scs.getString("official.institution.text.colour")); Locale locale = rb.getLocale(); List<Map<String, String>> saveciteClients = getConfigurationService().getSaveciteClientsForLocale(locale); if (saveciteClients != null) { if (resource != null && resourceId != null) { for (Map<String, String> client : saveciteClients) { String saveciteUrl = getSearchManager().getSaveciteUrl(resourceUuid, client.get("id")); try { client.put("saveciteUrl", java.net.URLEncoder.encode(saveciteUrl, "UTF-8")); } catch (UnsupportedEncodingException e) { logger.warn("Error encoding savecite URL", e); } } } context.put("saveciteClients", saveciteClients); } // determine which features to display if (getConfigurationService().isGoogleScholarEnabled()) { String googleUrl = getSearchManager().getGoogleScholarUrl(getContentService().getUuid(resourceId)); String sakaiInstance = scs.getString("ui.service", "Sakai"); context.put("googleUrl", googleUrl); // object array for formatted messages Object[] googleArgs = { rb.getFormattedMessage("linkLabel.google.sakai", sakaiInstance) }; context.put("googleArgs", googleArgs); } if (getConfigurationService().librarySearchEnabled()) { context.put("searchLibrary", Boolean.TRUE); } if (citationCollection == null || (citationCollection.size() <= 0 && unnestedCitationCollection.size() <= 0) && nestedCollection.getChildren().size() <= 0) { } else { context.put("openUrlLabel", getConfigurationService().getSiteConfigOpenUrlLabel()); String currentSort = (String) state.getAttribute(STATE_SORT); if (currentSort == null || currentSort.trim().length() == 0) currentSort = citationCollection.getSort(); if (currentSort == null || currentSort.trim().length() == 0) { currentSort = CitationCollection.SORT_BY_TITLE; } context.put("currentSort", currentSort); String savedSort = citationCollection.getSort(); if (savedSort == null || savedSort.trim().equals("")) { savedSort = CitationCollection.SORT_BY_TITLE; } if (savedSort != currentSort) { citationCollection.setSort(currentSort, true); } //context.put(PARAM_FORM_NAME, ELEMENT_ID_LIST_FORM); // collection size context.put("collectionSize", new Integer(citationCollection.size())); // export URLs String exportUrlSel = citationCollection.getUrl(CitationService.REF_TYPE_EXPORT_RIS_SEL); String exportUrlAll = citationCollection.getUrl(CitationService.REF_TYPE_EXPORT_RIS_ALL); context.put("exportUrlSel", exportUrlSel); context.put("exportUrlAll", exportUrlAll); Integer listPageSize = (Integer) state.getAttribute(STATE_LIST_PAGE_SIZE); if (listPageSize == null) { listPageSize = defaultListPageSize; state.setAttribute(STATE_LIST_PAGE_SIZE, listPageSize); } context.put("listPageSize", listPageSize); CitationIterator newIterator = citationCollection.iterator(); CitationIterator oldIterator = (CitationIterator) state.getAttribute(STATE_LIST_ITERATOR); if (oldIterator == null) { newIterator.setPageSize(listPageSize.intValue()); newIterator.setStart(0); } else { newIterator.setPageSize(listPageSize.intValue()); newIterator.setStart(oldIterator.getStart()); // newIterator.setPage(oldIterator.getPage()); } context.put("citations", newIterator); context.put("citationCollectionId", citationCollection.getId()); if (!citationCollection.isEmpty()) { context.put("show_citations", Boolean.TRUE); // int page = newIterator.getPage(); // int pageSize = newIterator.getPageSize(); int totalSize = citationCollection.size(); int start = newIterator.getStart(); int end = newIterator.getEnd(); // int start = page * pageSize + 1; // int end = Math.min((page + 1) * pageSize, totalSize); Integer[] position = { new Integer(start + 1), new Integer(end), new Integer(totalSize) }; String showing = (String) rb.getFormattedMessage("showing.results", position); context.put("showing", showing); } state.setAttribute(STATE_LIST_ITERATOR, newIterator); // constant schema identifier context.put("titleProperty", Schema.TITLE); int requestStateId = preserveRequestState(state, new String[] { CitationHelper.RESOURCES_REQUEST_PREFIX, CitationHelper.CITATION_PREFIX }); context.put("requestStateId", requestStateId); } return TEMPLATE_NEW_RESOURCE; }
From source file:org.openecomp.sdc.be.components.impl.ResourceBusinessLogic.java
/** * validateResourceFieldsBeforeUpdate//from w w w .j a v a2 s. c o m * * @param currentResource * - Resource object to validate * @return Either<Boolean, ErrorResponse> */ private Either<Boolean, ResponseFormat> validateResourceFieldsBeforeUpdate(Resource currentResource, Resource updateInfoResource, boolean inTransaction) { boolean hasBeenCertified = ValidationUtils.hasBeenCertified(currentResource.getVersion()); // validate resource name log.debug("validate resource name before update"); Either<Boolean, ResponseFormat> eitherValidation = validateResourceName(currentResource, updateInfoResource, hasBeenCertified); if (eitherValidation.isRight()) { return eitherValidation; } // validate description log.debug("validate description before update"); eitherValidation = validateDescriptionAndCleanup(null, updateInfoResource, null); if (eitherValidation.isRight()) { return eitherValidation; } log.debug("validate icon before update"); eitherValidation = validateIcon(currentResource, updateInfoResource, hasBeenCertified); if (eitherValidation.isRight()) { return eitherValidation; } log.debug("validate tags before update"); eitherValidation = validateTagsListAndRemoveDuplicates(null, updateInfoResource, null); if (eitherValidation.isRight()) { return eitherValidation; } log.debug("validate vendor name before update"); eitherValidation = validateVendorName(currentResource, updateInfoResource, hasBeenCertified); if (eitherValidation.isRight()) { return eitherValidation; } log.debug("validate vendor release before update"); eitherValidation = validateVendorReleaseName(null, updateInfoResource, null); if (eitherValidation.isRight()) { return eitherValidation; } log.debug("validate contact info before update"); eitherValidation = validateContactId(null, updateInfoResource, null); if (eitherValidation.isRight()) { return eitherValidation; } log.debug("validate derived before update"); eitherValidation = validateDerivedFromDuringUpdate(currentResource, updateInfoResource, hasBeenCertified); if (eitherValidation.isRight()) { return eitherValidation; } log.debug("validate category before update"); eitherValidation = validateCategory(currentResource, updateInfoResource, hasBeenCertified, inTransaction); if (eitherValidation.isRight()) { return eitherValidation; } // warn about non-updatable fields String currentResourceVersion = currentResource.getVersion(); String updatedResourceVersion = updateInfoResource.getVersion(); if ((updatedResourceVersion != null) && (!updatedResourceVersion.equals(currentResourceVersion))) { log.warn("Resource version is automatically set and cannot be updated"); } String currentCreatorUserId = currentResource.getCreatorUserId(); String updatedCreatorUserId = updateInfoResource.getCreatorUserId(); if ((updatedCreatorUserId != null) && (!updatedCreatorUserId.equals(currentCreatorUserId))) { log.warn("Resource Creator User id is automatically set and cannot be updated"); } String currentCreatorFullName = currentResource.getCreatorFullName(); String updatedCreatorFullName = updateInfoResource.getCreatorFullName(); if ((updatedCreatorFullName != null) && (!updatedCreatorFullName.equals(currentCreatorFullName))) { log.warn("Resource Creator fullname is automatically set and cannot be updated"); } String currentLastUpdaterUserId = currentResource.getLastUpdaterUserId(); String updatedLastUpdaterUserId = updateInfoResource.getLastUpdaterUserId(); if ((updatedLastUpdaterUserId != null) && (!updatedLastUpdaterUserId.equals(currentLastUpdaterUserId))) { log.warn("Resource LastUpdater userId is automatically set and cannot be updated"); } String currentLastUpdaterFullName = currentResource.getLastUpdaterFullName(); String updatedLastUpdaterFullName = updateInfoResource.getLastUpdaterFullName(); if ((updatedLastUpdaterFullName != null) && (!updatedLastUpdaterFullName.equals(currentLastUpdaterFullName))) { log.warn("Resource LastUpdater fullname is automatically set and cannot be updated"); } Long currentCreationDate = currentResource.getCreationDate(); Long updatedCreationDate = updateInfoResource.getCreationDate(); if ((updatedCreationDate != null) && (!updatedCreationDate.equals(currentCreationDate))) { log.warn("Resource Creation date is automatically set and cannot be updated"); } Long currentLastUpdateDate = currentResource.getLastUpdateDate(); Long updatedLastUpdateDate = updateInfoResource.getLastUpdateDate(); if ((updatedLastUpdateDate != null) && (!updatedLastUpdateDate.equals(currentLastUpdateDate))) { log.warn("Resource last update date is automatically set and cannot be updated"); } LifecycleStateEnum currentLifecycleState = currentResource.getLifecycleState(); LifecycleStateEnum updatedLifecycleState = updateInfoResource.getLifecycleState(); if ((updatedLifecycleState != null) && (!updatedLifecycleState.equals(currentLifecycleState))) { log.warn("Resource lifecycle state date is automatically set and cannot be updated"); } Boolean currentAbstract = currentResource.isAbstract(); Boolean updatedAbstract = updateInfoResource.isAbstract(); if ((updatedAbstract != null) && (!updatedAbstract.equals(currentAbstract))) { log.warn("Resource abstract is automatically set and cannot be updated"); } Boolean currentHighestVersion = currentResource.isHighestVersion(); Boolean updatedHighestVersion = updateInfoResource.isHighestVersion(); if ((updatedHighestVersion != null) && (!updatedHighestVersion.equals(currentHighestVersion))) { log.warn("Resource highest version is automatically set and cannot be updated"); } String currentUuid = currentResource.getUUID(); String updatedUuid = updateInfoResource.getUUID(); if ((updatedUuid != null) && (!updatedUuid.equals(currentUuid))) { log.warn("Resource UUID is automatically set and cannot be updated"); } ResourceTypeEnum currentResourceType = currentResource.getResourceType(); ResourceTypeEnum updatedResourceType = updateInfoResource.getResourceType(); if ((updatedResourceType != null) && (!updatedResourceType.equals(currentResourceType))) { log.warn("Resource Type cannot be updated"); } updateInfoResource.setResourceType(currentResource.getResourceType()); String currentInvariantUuid = currentResource.getInvariantUUID(); String updatedInvariantUuid = updateInfoResource.getInvariantUUID(); if ((updatedInvariantUuid != null) && (!updatedInvariantUuid.equals(currentInvariantUuid))) { log.warn("Resource invariant UUID is automatically set and cannot be updated"); updateInfoResource.setInvariantUUID(currentInvariantUuid); } return Either.left(true); }
From source file:org.etudes.component.app.jforum.JForumCategoryServiceImpl.java
/** * Check for date changes//from w w w. j a va 2 s. co m * * @param category Category with user input dates * * @param existingCategory Existing category * * @return true - if dates are changed * false - if dates are not changed */ protected boolean checkDatesChanged(Category category, Category existingCategory) { boolean datesChanged = false; Date exisCatOpenDate = null, exisCatDueDate = null, exisCatAllowUntilDate = null, modCatOpenDate = null, modCatDueDate = null, modCatAllowUntilDate = null; Boolean exisHideUntilOpen = null, modHideUntilOpen = null; if (category.getAccessDates() != null) { modCatOpenDate = category.getAccessDates().getOpenDate(); modHideUntilOpen = category.getAccessDates().isHideUntilOpen(); modCatDueDate = category.getAccessDates().getDueDate(); modCatAllowUntilDate = category.getAccessDates().getAllowUntilDate(); } if (existingCategory.getAccessDates() != null) { exisCatOpenDate = existingCategory.getAccessDates().getOpenDate(); exisHideUntilOpen = existingCategory.getAccessDates().isHideUntilOpen(); exisCatDueDate = existingCategory.getAccessDates().getDueDate(); exisCatAllowUntilDate = existingCategory.getAccessDates().getAllowUntilDate(); } /*if (exisCatOpenDate == null) { if (modCatOpenDate != null) { datesChanged = true; } } else { if (modCatOpenDate == null) { datesChanged = true; } else if (!modCatOpenDate.equals(exisCatOpenDate)) { datesChanged = true; } } if (!datesChanged) { if (exisCatDueDate == null) { if (modCatDueDate != null) { datesChanged = true; } } else { if (modCatDueDate == null) { datesChanged = true; } else if (!modCatDueDate.equals(exisCatDueDate)) { datesChanged = true; } } }*/ // open date if (exisCatOpenDate == null) { if (modCatOpenDate != null) { datesChanged = true; } } else { if (modCatOpenDate == null) { datesChanged = true; } else if (!modCatOpenDate.equals(exisCatOpenDate)) { datesChanged = true; } else if (modCatOpenDate.equals(exisCatOpenDate)) { if (!exisHideUntilOpen.equals(modHideUntilOpen)) { datesChanged = true; } } } // due date if (!datesChanged) { if (exisCatDueDate == null) { if (modCatDueDate != null) { datesChanged = true; } } else { if (modCatDueDate == null) { datesChanged = true; } else if (!modCatDueDate.equals(exisCatDueDate)) { datesChanged = true; } } } // allow until date if (!datesChanged) { if (exisCatAllowUntilDate == null) { if (modCatAllowUntilDate != null) { datesChanged = true; } } else { if (modCatAllowUntilDate == null) { datesChanged = true; } else if (!modCatAllowUntilDate.equals(exisCatAllowUntilDate)) { datesChanged = true; } } } return datesChanged; }
From source file:org.etudes.component.app.jforum.JForumPostServiceImpl.java
/** * Check for date changes/* ww w . j a va 2 s. c o m*/ * * @param topic Topic * * @param existingTopic Existing topic to compare * * @return true - if dates are changed * false - if dates are not changed */ protected boolean checkDatesChanged(Topic topic, Topic existingTopic) { boolean datesChanged = false; /*Date exisOpenDate = null, exisDueDate = null, modOpenDate = null, modDueDate = null; if (topic.getAccessDates() != null) { modOpenDate = topic.getAccessDates().getOpenDate(); modDueDate = topic.getAccessDates().getDueDate(); } if (existingTopic.getAccessDates() != null) { exisOpenDate = existingTopic.getAccessDates().getOpenDate(); exisDueDate = existingTopic.getAccessDates().getDueDate(); } if (exisOpenDate == null) { if (modOpenDate != null) { datesChanged = true; } } else { if (modOpenDate == null) { datesChanged = true; } else if (!modOpenDate.equals(exisOpenDate)) { datesChanged = true; } } if (!datesChanged) { if (exisDueDate == null) { if (modDueDate != null) { datesChanged = true; } } else { if (modDueDate == null) { datesChanged = true; } else if (!modDueDate.equals(exisDueDate)) { datesChanged = true; } } }*/ Date exisOpenDate = null, exisDueDate = null, exisAllowUntilDate = null, modOpenDate = null, modDueDate = null, modAllowUntilDate = null; Boolean exisHideUntilOpen = null, modHideUntilOpen = null; if (topic.getAccessDates() != null) { modOpenDate = topic.getAccessDates().getOpenDate(); modHideUntilOpen = topic.getAccessDates().isHideUntilOpen(); modDueDate = topic.getAccessDates().getDueDate(); modAllowUntilDate = topic.getAccessDates().getAllowUntilDate(); } if (existingTopic.getAccessDates() != null) { exisOpenDate = existingTopic.getAccessDates().getOpenDate(); exisHideUntilOpen = existingTopic.getAccessDates().isHideUntilOpen(); exisDueDate = existingTopic.getAccessDates().getDueDate(); exisAllowUntilDate = existingTopic.getAccessDates().getAllowUntilDate(); } // open date if (exisOpenDate == null) { if (modOpenDate != null) { datesChanged = true; } } else { if (modOpenDate == null) { datesChanged = true; } else if (!modOpenDate.equals(exisOpenDate)) { datesChanged = true; } else if (modOpenDate.equals(exisOpenDate)) { if (!exisHideUntilOpen.equals(modHideUntilOpen)) { datesChanged = true; } } } // due date if (!datesChanged) { if (exisDueDate == null) { if (modDueDate != null) { datesChanged = true; } } else { if (modDueDate == null) { datesChanged = true; } else if (!modDueDate.equals(exisDueDate)) { datesChanged = true; } } } // allow until date if (!datesChanged) { if (exisAllowUntilDate == null) { if (modAllowUntilDate != null) { datesChanged = true; } } else { if (modAllowUntilDate == null) { datesChanged = true; } else if (!modAllowUntilDate.equals(exisAllowUntilDate)) { datesChanged = true; } } } return datesChanged; }
From source file:org.hyperic.hq.bizapp.server.session.MeasurementBossImpl.java
/** * Fetch the metric summaries for specified resources and templates * @param resources the list of resources * @param tmpls the list of measurement templates * @param begin the beginning of time range * @param end the end of time range//w ww. j a v a 2s. c o m * @param showNoCollect whether or not to include templates that have not * collected data * @return Map where key = category, value = List of summary beans */ private Map<String, Set<MetricDisplaySummary>> getResourceMetrics(AuthzSubject subject, List resources, List tmpls, long begin, long end, Boolean showNoCollect) throws AppdefCompatException { List<MeasurementTemplate> templates; Integer[] tids; // Create Map of all resources final int size = MeasurementConstants.VALID_CATEGORIES.length; HashMap<String, Set<MetricDisplaySummary>> resmap = new HashMap<String, Set<MetricDisplaySummary>>(size); if (tmpls.size() == 0 || resources.size() == 0) { return resmap; } if (tmpls.get(0) instanceof MeasurementTemplate) { templates = tmpls; tids = new Integer[templates.size()]; for (int i = 0; i < templates.size(); i++) { MeasurementTemplate t = templates.get(i); tids[i] = t.getId(); } } else { // If templates are just ID's, we have to look them up tids = (Integer[]) tmpls.toArray(new Integer[tmpls.size()]); try { templates = templateManager.getTemplates(tids, PageControl.PAGE_ALL); } catch (TemplateNotFoundException e) { templates = new ArrayList<MeasurementTemplate>(0); // Well, if we don't find it, *shrug* } } // Create the EntityIds array and map of counts Integer[] eids = new Integer[resources.size()]; AppdefEntityID[] aeids = new AppdefEntityID[resources.size()]; Map<String, Integer> totalCounts = new HashMap<String, Integer>(); Map<Integer, Collection<AppdefEntityID>> aeidsByType = new HashMap<Integer, Collection<AppdefEntityID>>(); int i = 0; for (Iterator<Object> it = resources.iterator(); it.hasNext(); i++) { // We understand two types AppdefEntityID aeid; Object resource = it.next(); if (resource instanceof AppdefResourceValue) { AppdefResourceValue resVal = (AppdefResourceValue) resource; aeid = resVal.getEntityId(); // Increase count String type = resVal.getAppdefResourceTypeValue().getName(); int count = 0; if (totalCounts.containsKey(type)) { count = totalCounts.get(type).intValue(); } totalCounts.put(type, new Integer(++count)); } else if (resource instanceof AppdefEntityID) { aeid = (AppdefEntityID) resource; } else { throw new AppdefCompatException( "getResourceMetrics() does " + "not understand resource class: " + resource.getClass()); } Collection<AppdefEntityID> tmp; if (null == (tmp = aeidsByType.get(aeid.getType()))) { tmp = new ArrayList<AppdefEntityID>(); aeidsByType.put(aeid.getType(), tmp); } tmp.add(aeid); eids[i] = aeid.getId(); aeids[i] = aeid; } // Now get the aggregate data, keyed by template ID's final List<Measurement> measurements = measurementManager.getEnabledMeasurements(tids, eids); final Map<Integer, double[]> datamap = dataManager.getAggregateDataByTemplate(measurements, begin, end); // Get the intervals, keyed by template ID's as well final Map<Integer, Long> intervals = (showNoCollect == null) ? new HashMap<Integer, Long>() : measurementManager.findMetricIntervals(subject, aeids, tids); final Map<Integer, ProblemMetricInfo> probmap = new HashMap<Integer, ProblemMetricInfo>(); for (Integer aeidType : aeidsByType.keySet()) { probmap.putAll(problemMetricManager.getProblemsByTemplate(aeidType, eids, begin, end)); } for (Iterator<MeasurementTemplate> it = templates.iterator(); it.hasNext();) { MeasurementTemplate tmpl = it.next(); int total = eids.length; String type = tmpl.getMonitorableType().getName(); if (totalCounts.containsKey(type)) { total = totalCounts.get(type).intValue(); } double[] data = datamap.get(tmpl.getId()); if (data == null && (showNoCollect == null || showNoCollect.equals(Boolean.FALSE))) { continue; } String category = tmpl.getCategory().getName(); Set<MetricDisplaySummary> summaries = resmap.get(category); if (summaries == null) { summaries = new TreeSet<MetricDisplaySummary>(); resmap.put(category, summaries); } Long interval = intervals.get(tmpl.getId()); // Now create a MetricDisplaySummary and add it to the list MetricDisplaySummary summary = getMetricDisplaySummary(tmpl, interval, begin, end, data, total); if (data != null) { // See if there are problems, too if (probmap.containsKey(tmpl.getId())) { ProblemMetricInfo pmi = probmap.get(tmpl.getId()); summary.setAlertCount(pmi.getAlertCount()); summary.setOobCount(pmi.getOobCount()); } } summaries.add(summary); } return resmap; }
From source file:org.sakaiproject.content.tool.ResourcesAction.java
/** * Build the context to show the list of resource properties *//*from w ww . jav a2 s .com*/ public String buildMoreContext(VelocityPortlet portlet, Context context, RunData data, SessionState state) { logger.debug("ResourcesAction.buildMoreContext()"); context.put("tlang", rb); // find the ContentTypeImage service context.put("contentTypeImageService", state.getAttribute(STATE_CONTENT_TYPE_IMAGE_SERVICE)); String entityId = (String) state.getAttribute(STATE_MORE_ID); context.put("id", entityId); String collectionId = (String) state.getAttribute(STATE_MORE_COLLECTION_ID); context.put("collectionId", collectionId); String homeCollectionId = (String) (String) state.getAttribute(STATE_HOME_COLLECTION_ID); context.put("homeCollectionId", homeCollectionId); //List cPath = getCollectionPath(state); //context.put ("collectionPath", cPath); String navRoot = (String) state.getAttribute(STATE_NAVIGATION_ROOT); context.put("navRoot", navRoot); ListItem item = new ListItem(entityId); context.put("item", item); if (state.getAttribute(STATE_MESSAGE) == null) { context.put("notExistFlag", Boolean.valueOf(false)); } if (RESOURCES_MODE_DROPBOX.equalsIgnoreCase((String) state.getAttribute(STATE_MODE_RESOURCES))) { // notshow the public option or notification when in dropbox mode context.put("dropboxMode", Boolean.TRUE); } else { //context.put("dropboxMode", Boolean.FALSE); Boolean preventPublicDisplay = (Boolean) state.getAttribute(STATE_PREVENT_PUBLIC_DISPLAY); if (preventPublicDisplay == null) { preventPublicDisplay = Boolean.FALSE; state.setAttribute(STATE_PREVENT_PUBLIC_DISPLAY, preventPublicDisplay); } context.put("preventPublicDisplay", preventPublicDisplay); if (preventPublicDisplay.equals(Boolean.FALSE)) { // find out about pubview boolean pubview = ContentHostingService.isInheritingPubView(entityId); if (!pubview) pubview = ContentHostingService.isPubView(entityId); context.put("pubview", Boolean.valueOf(pubview)); } } context.put("siteTitle", state.getAttribute(STATE_SITE_TITLE)); if (item.isUrl()) { context.put("contentString", getEditItem(entityId, homeCollectionId, data).getContentstring()); } return TEMPLATE_MORE; }