List of usage examples for java.util List sort
@SuppressWarnings({ "unchecked", "rawtypes" }) default void sort(Comparator<? super E> c)
From source file:org.cgiar.ccafs.marlo.action.BaseAction.java
/** * validate if the list of phases are on session if not, will be find on bd on json format * /* w w w .jav a 2 s . c o m*/ * @return the jsons of the phases for the crp */ public String getPhasesJson() { List<Phase> phases; if (this.getSession().containsKey(APConstants.PHASES)) { phases = (List<Phase>) this.getSession().get(APConstants.PHASES); } else { phases = phaseManager.findAll().stream() .filter(c -> c.getCrp().getId().longValue() == this.getCrpID().longValue() && c.getVisible() != null && c.getVisible()) .collect(Collectors.toList()); phases.sort((p1, p2) -> new Integer(p1.getYear()).compareTo(new Integer(p2.getYear()))); this.getSession().put(APConstants.PHASES, phases); } GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create(); return gson.toJson(phases); }
From source file:org.cgiar.ccafs.marlo.action.BaseAction.java
public String getPhasesImpactJson() { List<Phase> phases; if (this.getSession().containsKey(APConstants.PHASES_IMPACT)) { phases = (List<Phase>) this.getSession().get(APConstants.PHASES_IMPACT); } else {/*from ww w .j a v a 2 s .c om*/ phases = phaseManager.findAll().stream() .filter(c -> c.getCrp().getId().longValue() == this.getCrpID().longValue() && c.getVisible() != null && c.getVisible() && c.getDescription().equals(APConstants.PLANNING)) .collect(Collectors.toList()); phases.sort((p1, p2) -> new Integer(p1.getYear()).compareTo(new Integer(p2.getYear()))); this.getSession().put(APConstants.PHASES_IMPACT, phases); } GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create(); return gson.toJson(phases); }
From source file:burstcoin.observer.service.AssetService.java
private void startCheckAssetsTask() { timer.schedule(new TimerTask() { @Override// w w w .j a va 2s .c om public void run() { try { LOG.info("START import asset data from " + ObserverProperties.getWalletUrl()); Map<String, Asset> assetLookup = createAssetLookup(); Map<OrderType, Map<Asset, List<Order>>> orderLookup = createOrderLookup(assetLookup); Map<Asset, List<Trade>> tradeLookup = getTradeLookup(assetLookup); State state = getState(); LOG.info("FINISH import asset data!"); List<AssetBean> assetBeans = new ArrayList<>(); List<AssetCandleStickBean> assetCandleStickBeans = new ArrayList<>(); for (Asset asset : assetLookup.values()) { List<List> candleStickData = new ArrayList<List>(); long volume7Days = 0L; long volume30Days = 0L; String lastPrice = ""; List<Trade> trades = tradeLookup.get(asset); if (trades != null && !trades.isEmpty()) { Iterator<Trade> iterator = trades.iterator(); boolean withinLast30Days = true; while (withinLast30Days && iterator.hasNext()) { Trade trade = iterator.next(); if (StringUtils.isEmpty(lastPrice)) { lastPrice = convertPrice(trade.getPriceNQT(), trade.getDecimals()); } Integer bidOrderBlock = Integer.valueOf(trade.getBidOrderHeight()); Integer askOrderBlock = Integer.valueOf(trade.getAskOrderHeight()); int block = bidOrderBlock >= askOrderBlock ? bidOrderBlock : askOrderBlock; withinLast30Days = state.getNumberOfBlocks() - 360 * 30 < block; if (withinLast30Days) { long volume = Long.valueOf(trade.getPriceNQT()) * Long.valueOf(trade.getQuantityQNT()); volume30Days += volume; if (state.getNumberOfBlocks() - 360 * 7 < block) { volume7Days += volume; } } } Long currentBlockHeight = Long.valueOf(state.getNumberOfBlocks()); for (int i = 1; i <= 60 /*days*/; i++) { List<Trade> tradesOfDay = new ArrayList<Trade>(); for (Trade trade : trades) { if (trade.getHeight() > currentBlockHeight - (360 * (i + 1)) && trade.getHeight() < currentBlockHeight - (360 * i)) { tradesOfDay.add(trade); } } Double min = null; Double max = null; Double first = null; Double last = null; for (Trade trade : tradesOfDay) { double price = Double .valueOf(convertPrice(trade.getPriceNQT(), trade.getDecimals())); if (first == null) { first = price; } if (min == null || price < min) { min = price; } if (max == null || price > max) { max = price; } if (tradesOfDay.indexOf(trade) == tradesOfDay.size() - 1) { last = price; } } if (min != null && max != null && first != null && last != null) { List x = Arrays.asList("" + i, min, first, last, max); candleStickData.add(x); } else { candleStickData.add(Arrays.asList("" + i, null, null, null, null)); } } } Collections.reverse(candleStickData); List<Order> sellOrders = orderLookup.get(OrderType.ASK).get(asset) != null ? orderLookup.get(OrderType.ASK).get(asset) : new ArrayList<>(); List<Order> buyOrders = orderLookup.get(OrderType.BID).get(asset) != null ? orderLookup.get(OrderType.BID).get(asset) : new ArrayList<>(); if (!(buyOrders.isEmpty() && sellOrders.isEmpty() && asset.getNumberOfTrades() < 2)) { assetBeans.add(new AssetBean(asset.getAsset(), asset.getName(), asset.getDescription(), asset.getAccountRS(), asset.getAccount(), asset.getQuantityQNT(), asset.getDecimals(), asset.getNumberOfAccounts(), asset.getNumberOfTransfers(), asset.getNumberOfTrades(), buyOrders.size(), sellOrders.size(), formatAmountNQT(volume7Days, 8), formatAmountNQT(volume30Days, 8), lastPrice)); assetCandleStickBeans.add(new AssetCandleStickBean(asset.getAsset(), candleStickData)); } } Collections.sort(assetBeans, new Comparator<AssetBean>() { @Override public int compare(AssetBean o1, AssetBean o2) { return Long.valueOf(o2.getVolume30Days()).compareTo(Long.valueOf(o1.getVolume30Days())); } }); Collections.sort(assetBeans, new Comparator<AssetBean>() { @Override public int compare(AssetBean o1, AssetBean o2) { return Long.valueOf(o2.getVolume7Days()).compareTo(Long.valueOf(o1.getVolume7Days())); } }); // delete data of candleStick for all after index 24 todo remove as soon ui has show/hide charts per asset List<String> assetOrder = new ArrayList<String>(); for (AssetBean assetBean : assetBeans) { assetOrder.add(assetBean.getAsset()); } assetCandleStickBeans.sort(new Comparator<AssetCandleStickBean>() { @Override public int compare(AssetCandleStickBean o1, AssetCandleStickBean o2) { return ((Integer) assetOrder.indexOf(o1.getAsset())) .compareTo(assetOrder.indexOf(o2.getAsset())); } }); publisher.publishEvent(new AssetUpdateEvent(assetBeans, assetCandleStickBeans)); } catch (Exception e) { LOG.error("Failed update assets!", e); } } }, 200, ObserverProperties.getAssetRefreshInterval()); }
From source file:org.cgiar.ccafs.marlo.action.summaries.ReportingSummaryAction.java
private TypedTableModel getDeliverablesReportingTableModel() { TypedTableModel model = new TypedTableModel(new String[] { "deliverable_id", "title", "deliv_type", "deliv_sub_type", "deliv_status", "deliv_year", "key_output", "leader", "institution", "funding_sources", "cross_cutting", "deliv_new_year", "deliv_new_year_justification", "deliv_dissemination_channel", "deliv_dissemination_url", "deliv_open_access", "deliv_license", "titleMetadata", "descriptionMetadata", "dateMetadata", "languageMetadata", "countryMetadata", "keywordsMetadata", "citationMetadata", "HandleMetadata", "DOIMetadata", "creator_authors", "data_sharing", "qualityAssurance", "dataDictionary", "tools", "showFAIR", "F", "A", "I", "R", "isDisseminated", "disseminated", "restricted_access", "isRestricted", "restricted_date", "isLastTwoRestricted", "deliv_license_modifications", "show_deliv_license_modifications", "volume", "issue", "pages", "journal", "journal_indicators", "acknowledge", "fl_contrib", "show_publication", "showCompilance", "deliv_description", "hasIntellectualAsset", "isPantent", "isPvp", "hasParticipants", "isAcademicDegree", "isRegional", "isNational", "hasParticipantsText", "participantEvent", "participantActivityType", "participantAcademicDegree", "participantTotalParticipants", "participantFemales", "participantType", "participantGeographicScope", "participantRegional", "participantCountries", "hasIntellectualAssetText", "intellectualAssetApplicants", "intellectualAssetType", "intellectualAssetTitle", "intellectualAssetFillingType", "intellectualAssetPantentStatus", "intellectualAssetPatentType", "intellectualAssetPvpVarietyName", "intellectualAssetPvpStatus", "intellectualAssetPvpCountry", "intellectualAssetPvpApplicationNumber", "intellectualAssetPvpBreederCrop", "intellectualAssetDateFilling", "intellectualAssetDateRegistration", "intellectualAssetDateExpiry", "intellectualAssetAdditionalInformation", "intellectualAssetLinkPublished", "intellectualAssetCommunication" }, new Class[] { Long.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, Boolean.class, String.class, String.class, String.class, String.class, Boolean.class, String.class, String.class, Boolean.class, String.class, Boolean.class, String.class, Boolean.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, Boolean.class, Boolean.class, String.class, Boolean.class, Boolean.class, Boolean.class, Boolean.class, Boolean.class, Boolean.class, Boolean.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class }, 0);/* ww w. j av a 2s. c om*/ SimpleDateFormat formatter = new SimpleDateFormat("MMM yyyy"); if (!project.getDeliverables().isEmpty()) { // get Reporting deliverables List<Deliverable> deliverables = project.getDeliverables().stream().filter(d -> d.isActive() && d.getProject() != null && d.getProject().isActive() && d.getProject().getGlobalUnitProjects().stream() .filter(gup -> gup.isActive() && gup.getGlobalUnit().getId().equals(this.getLoggedCrp().getId())) .collect(Collectors.toList()).size() > 0 && d.getDeliverableInfo(this.getSelectedPhase()) != null && d.getDeliverableInfo(this.getSelectedPhase()).getStatus() != null && ((d.getDeliverableInfo(this.getSelectedPhase()).getStatus().intValue() == Integer .parseInt(ProjectStatusEnum.Complete.getStatusId()) && (d.getDeliverableInfo(this.getSelectedPhase()).getYear() >= this.getSelectedYear() || (d.getDeliverableInfo(this.getSelectedPhase()).getNewExpectedYear() != null && d.getDeliverableInfo(this.getSelectedPhase()).getNewExpectedYear() .intValue() >= this.getSelectedYear()))) || (d.getDeliverableInfo(this.getSelectedPhase()).getStatus().intValue() == Integer .parseInt(ProjectStatusEnum.Extended.getStatusId()) && (d.getDeliverableInfo(this.getSelectedPhase()).getNewExpectedYear() != null && d.getDeliverableInfo(this.getSelectedPhase()).getNewExpectedYear() .intValue() == this.getSelectedYear())) || (d.getDeliverableInfo(this.getSelectedPhase()).getStatus().intValue() == Integer .parseInt(ProjectStatusEnum.Cancelled.getStatusId()) && (d.getDeliverableInfo(this.getSelectedPhase()).getYear() == this .getSelectedYear() || (d.getDeliverableInfo(this.getSelectedPhase()) .getNewExpectedYear() != null && d.getDeliverableInfo(this.getSelectedPhase()) .getNewExpectedYear() .intValue() == this.getSelectedYear())))) && (d.getDeliverableInfo(this.getSelectedPhase()).getStatus().intValue() == Integer .parseInt(ProjectStatusEnum.Extended.getStatusId()) || d.getDeliverableInfo(this.getSelectedPhase()).getStatus().intValue() == Integer .parseInt(ProjectStatusEnum.Complete.getStatusId()) || d.getDeliverableInfo(this.getSelectedPhase()).getStatus().intValue() == Integer .parseInt(ProjectStatusEnum.Cancelled.getStatusId()))) .collect(Collectors.toList()); deliverables.sort((p1, p2) -> p1.getDeliverableInfo(this.getSelectedPhase()) .isRequieriedReporting(this.getSelectedYear()) .compareTo(p2.getDeliverableInfo(this.getSelectedPhase()) .isRequieriedReporting(this.getSelectedYear()))); HashSet<Deliverable> deliverablesHL = new HashSet<>(); deliverablesHL.addAll(deliverables); deliverables.clear(); deliverables.addAll(deliverablesHL); for (Deliverable deliverable : deliverables) { String delivType = null, delivSubType = null, delivYear = null, keyOutput = "", leader = null, institution = null, fundingSources = "", deliv_description = null; String delivStatus = deliverable.getDeliverableInfo(this.getSelectedPhase()) .getStatusName(this.getSelectedPhase()); Boolean showFAIR = false, showPublication = false, showCompilance = false; if (deliverable.getDeliverableInfo().getDescription() != null && !deliverable.getDeliverableInfo().getDescription().isEmpty()) { deliv_description = deliverable.getDeliverableInfo().getDescription(); } if (deliverable.getDeliverableInfo().getDeliverableType() != null) { DeliverableType deliverableSubType = deliverable.getDeliverableInfo().getDeliverableType(); delivSubType = deliverableSubType.getName(); if (deliverableSubType.getFair() != null && deliverableSubType.getFair()) { showFAIR = true; } showCompilance = this.hasDeliverableRule(deliverable.getDeliverableInfo(), APConstants.DELIVERABLE_RULE_COMPILANCE_CHECK); showPublication = this.hasDeliverableRule(deliverable.getDeliverableInfo(), APConstants.DELIVERABLE_RULE_PUBLICATION_METADATA); if (deliverableSubType.getDeliverableCategory() != null) { DeliverableType deliverableType = deliverableSubType.getDeliverableCategory(); delivType = deliverableType.getName(); if (deliverableType.getFair() != null && deliverableType.getFair()) { showFAIR = true; } } } if (delivStatus.equals("")) { delivStatus = null; } if (deliverable.getDeliverableInfo().getYear() != 0) { delivYear = "" + deliverable.getDeliverableInfo().getYear(); } if (deliverable.getDeliverableInfo().getCrpClusterKeyOutput() != null) { keyOutput += "? "; if (deliverable.getDeliverableInfo().getCrpClusterKeyOutput().getCrpClusterOfActivity() .getCrpProgram() != null) { keyOutput += deliverable.getDeliverableInfo().getCrpClusterKeyOutput() .getCrpClusterOfActivity().getCrpProgram().getAcronym() + " - "; } keyOutput += deliverable.getDeliverableInfo().getCrpClusterKeyOutput().getKeyOutput(); } // Get partner responsible and institution List<DeliverablePartnership> deliverablePartnershipResponsibles = deliverablePartnershipManager .findByDeliverablePhaseAndType(deliverable.getId(), this.getSelectedPhase().getId(), DeliverablePartnershipTypeEnum.RESPONSIBLE.getValue()); if (deliverablePartnershipResponsibles != null && deliverablePartnershipResponsibles.size() > 0) { if (deliverablePartnershipResponsibles.size() > 1) { LOG.warn("There are more than 1 deliverable responsibles for D" + deliverable.getId() + " " + this.getSelectedPhase().toString()); } DeliverablePartnership responisble = deliverablePartnershipResponsibles.get(0); if (responisble != null) { if (responisble.getProjectPartnerPerson() != null) { ProjectPartnerPerson responsibleppp = responisble.getProjectPartnerPerson(); leader = responsibleppp.getUser().getComposedName() + "<br><" + responsibleppp.getUser().getEmail() + ">"; if (responsibleppp.getProjectPartner() != null) { if (responsibleppp.getProjectPartner().getInstitution() != null) { institution = responsibleppp.getProjectPartner().getInstitution() .getComposedName(); } } } } } // Get funding sources if exist for (DeliverableFundingSource dfs : deliverable.getDeliverableFundingSources().stream() .filter(d -> d.isActive() && d.getPhase() != null && d.getPhase().equals(this.getSelectedPhase()) && d.getFundingSource().getFundingSourceInfo(this.getSelectedPhase()) != null) .collect(Collectors.toList())) { fundingSources += "? " + dfs.getFundingSource().getComposedName() + "<br>"; } if (fundingSources.isEmpty()) { fundingSources = null; } // Get cross_cutting dimension String crossCutting = ""; if (deliverable.getDeliverableInfo(this.getSelectedPhase()).getCrossCuttingNa() != null) { if (deliverable.getDeliverableInfo(this.getSelectedPhase()).getCrossCuttingNa() == true) { crossCutting += " ? N/A <br>"; } } if (deliverable.getDeliverableInfo(this.getSelectedPhase()).getCrossCuttingGender() != null) { if (deliverable.getDeliverableInfo(this.getSelectedPhase()).getCrossCuttingGender() == true) { Long scoring = deliverable.getDeliverableInfo().getCrossCuttingScoreGender(); if (scoring != null) { CrossCuttingScoring crossCuttingScoring = crossCuttingScoringManager .getCrossCuttingScoringById(scoring); crossCutting += " ? Gender (" + crossCuttingScoring.getDescription() + ")<br>"; } else { crossCutting += " ? Gender <br>"; } } } if (deliverable.getDeliverableInfo(this.getSelectedPhase()).getCrossCuttingYouth() != null) { if (deliverable.getDeliverableInfo(this.getSelectedPhase()).getCrossCuttingYouth() == true) { Long scoring = deliverable.getDeliverableInfo().getCrossCuttingScoreYouth(); if (scoring != null) { CrossCuttingScoring crossCuttingScoring = crossCuttingScoringManager .getCrossCuttingScoringById(scoring); crossCutting += " ? Youth (" + crossCuttingScoring.getDescription() + ")<br>"; } else { crossCutting += " ? Youth <br>"; } } } if (deliverable.getDeliverableInfo(this.getSelectedPhase()).getCrossCuttingCapacity() != null) { if (deliverable.getDeliverableInfo(this.getSelectedPhase()).getCrossCuttingCapacity() == true) { Long scoring = deliverable.getDeliverableInfo().getCrossCuttingScoreCapacity(); if (scoring != null) { CrossCuttingScoring crossCuttingScoring = crossCuttingScoringManager .getCrossCuttingScoringById(scoring); crossCutting += " ? Capacity Development (" + crossCuttingScoring.getDescription() + ")<br>"; } else { crossCutting += " ? Capacity Development <br>"; } } } if (deliverable.getDeliverableInfo(this.getSelectedPhase()).getCrossCuttingGender() != null) { if (deliverable.getDeliverableInfo(this.getSelectedPhase()).getCrossCuttingGender() == true) { if (deliverable.getDeliverableGenderLevels() == null || deliverable.getDeliverableGenderLevels().isEmpty()) { crossCutting += "<br><b>Gender level(s):</b><br> <Not Defined>"; } else { crossCutting += "<br><b>Gender level(s): </b><br>"; for (DeliverableGenderLevel dgl : deliverable.getDeliverableGenderLevels().stream() .filter(dgl -> dgl.isActive() && dgl.getPhase() != null && dgl.getPhase().equals(this.getSelectedPhase())) .collect(Collectors.toList())) { if (dgl.getGenderLevel() != 0.0) { crossCutting += " ? " + genderTypeManager .getGenderTypeById(dgl.getGenderLevel()).getDescription() + "<br>"; } } } } } if (crossCutting.isEmpty()) { crossCutting = null; } if (keyOutput.isEmpty()) { keyOutput = null; } // Reporting Integer delivNewYear = null; String delivNewYearJustification = null; if (deliverable.getDeliverableInfo().getStatus() != null) { // Extended if (deliverable.getDeliverableInfo().getStatus().intValue() == Integer .parseInt(ProjectStatusEnum.Extended.getStatusId())) { if (deliverable.getDeliverableInfo().getNewExpectedYear() != null && deliverable.getDeliverableInfo().getNewExpectedYear().intValue() != -1) { delivNewYear = deliverable.getDeliverableInfo().getNewExpectedYear(); } delivNewYearJustification = deliverable.getDeliverableInfo().getStatusDescription(); } // Cancelled if (deliverable.getDeliverableInfo().getStatus().intValue() == Integer .parseInt(ProjectStatusEnum.Cancelled.getStatusId())) { delivNewYearJustification = deliverable.getDeliverableInfo().getStatusDescription(); } } String delivDisseminationChannel = null; String delivDisseminationUrl = null; String delivOpenAccess = null; String delivLicense = null; String delivLicenseModifications = null; Boolean isDisseminated = false; String disseminated = "No"; String restrictedAccess = null; String restrictedDate = null; Boolean isRestricted = false; Boolean isLastTwoRestricted = false; Boolean showDelivLicenseModifications = false; if (deliverable.getDeliverableDisseminations().stream().collect(Collectors.toList()).size() > 0 && deliverable.getDeliverableDisseminations().stream().collect(Collectors.toList()) .get(0) != null) { // Get deliverable dissemination DeliverableDissemination deliverableDissemination = deliverable.getDeliverableDisseminations() .stream().collect(Collectors.toList()).get(0); if (deliverableDissemination.getAlreadyDisseminated() != null && deliverableDissemination.getAlreadyDisseminated() == true) { isDisseminated = true; disseminated = "Yes"; } if (deliverableDissemination.getDisseminationChannel() != null && !deliverableDissemination.getDisseminationChannel().isEmpty()) { RepositoryChannel repositoryChannel = repositoryChannelManager .getRepositoryChannelByShortName( deliverableDissemination.getDisseminationChannel()); if (repositoryChannel != null) { delivDisseminationChannel = repositoryChannel.getName(); } } if (deliverableDissemination.getDisseminationUrl() != null && !deliverableDissemination.getDisseminationUrl().isEmpty()) { delivDisseminationUrl = deliverableDissemination.getDisseminationUrl().replace(" ", "%20"); } if (deliverableDissemination.getIsOpenAccess() != null) { if (deliverableDissemination.getIsOpenAccess() == true) { delivOpenAccess = "Yes"; } else { // get the open access delivOpenAccess = "No"; isRestricted = true; if (deliverableDissemination.getIntellectualProperty() != null && deliverableDissemination.getIntellectualProperty() == true) { restrictedAccess = "Intellectual Property Rights (confidential information)"; } if (deliverableDissemination.getLimitedExclusivity() != null && deliverableDissemination.getLimitedExclusivity() == true) { restrictedAccess = "Limited Exclusivity Agreements"; } if (deliverableDissemination.getNotDisseminated() != null && deliverableDissemination.getNotDisseminated() == true) { restrictedAccess = "Not Disseminated"; } if (deliverableDissemination.getRestrictedUseAgreement() != null && deliverableDissemination.getRestrictedUseAgreement() == true) { restrictedAccess = "Restricted Use AgreementOCS - Restricted access (if so, what are these periods?)"; isLastTwoRestricted = true; if (deliverableDissemination.getRestrictedAccessUntil() != null) { restrictedDate = "<b>Restricted access until: </b>" + deliverableDissemination.getRestrictedAccessUntil(); } else { restrictedDate = "<b>Restricted access until: </b><Not Defined>"; } } if (deliverableDissemination.getEffectiveDateRestriction() != null && deliverableDissemination.getEffectiveDateRestriction() == true) { restrictedAccess = "Effective Date Restriction - embargoed periods (if so, what are these periods?)"; isLastTwoRestricted = true; if (deliverableDissemination.getRestrictedEmbargoed() != null) { restrictedDate = "<b>Restricted embargoed date: </b>" + deliverableDissemination.getRestrictedEmbargoed(); } else { restrictedDate = "<b>Restricted embargoed date: </b><Not Defined>"; } } } } if (deliverable.getDeliverableInfo().getAdoptedLicense() != null) { if (deliverable.getDeliverableInfo().getAdoptedLicense() == true) { delivLicense = deliverable.getDeliverableInfo().getLicense(); if (delivLicense.equals("OTHER")) { delivLicense = deliverable.getDeliverableInfo().getOtherLicense(); showDelivLicenseModifications = true; if (deliverable.getDeliverableInfo().getAllowModifications() != null && deliverable.getDeliverableInfo().getAllowModifications() == true) { delivLicenseModifications = "Yes"; } else { delivLicenseModifications = "No"; } } } else { delivLicense = "No"; } } } if (delivLicense != null && delivLicense.isEmpty()) { delivLicense = null; } // Intellectual Assets Boolean hasIntellectualAsset = false, isPantent = false, isPvp = false; String hasIntellectualAssetText = null, intellectualAssetApplicants = null, intellectualAssetType = null, intellectualAssetTitle = null, intellectualAssetFillingType = null, intellectualAssetPantentStatus = null, intellectualAssetPatentType = null, intellectualAssetPvpVarietyName = null, intellectualAssetPvpStatus = null, intellectualAssetPvpCountry = null, intellectualAssetPvpApplicationNumber = null, intellectualAssetPvpBreederCrop = null, intellectualAssetDateFilling = null, intellectualAssetDateRegistration = null, intellectualAssetDateExpiry = null, intellectualAssetAdditionalInformation = null, intellectualAssetLinkPublished = null, intellectualAssetCommunication = null; List<DeliverableIntellectualAsset> intellectualAssets = deliverable .getDeliverableIntellectualAssets().stream() .filter(c -> c.isActive() && c.getPhase().equals(this.getActualPhase())) .collect(Collectors.toList()); if (intellectualAssets != null && intellectualAssets.size() > 0) { DeliverableIntellectualAsset asset = intellectualAssets.get(0); if (asset.getHasPatentPvp() != null) { hasIntellectualAsset = asset.getHasPatentPvp(); if (asset.getHasPatentPvp()) { hasIntellectualAssetText = "Yes"; if (asset.getApplicant() != null && !asset.getApplicant().isEmpty()) { intellectualAssetApplicants = asset.getApplicant(); } if (asset.getType() != null && asset.getType().intValue() != -1) { intellectualAssetType = DeliverableIntellectualAssetTypeEnum .getValue(asset.getType()).getType(); if (DeliverableIntellectualAssetTypeEnum.getValue(asset.getType()) .equals(DeliverableIntellectualAssetTypeEnum.Patent)) { // Patent isPantent = true; if (asset.getFillingType() != null && asset.getFillingType().getId() != -1) { intellectualAssetFillingType = asset.getFillingType().getName(); } if (asset.getPatentStatus() != null && asset.getPatentStatus().getId() != -1) { intellectualAssetPantentStatus = asset.getPatentStatus().getName(); } if (asset.getPatentType() != null && asset.getPatentType().intValue() != -1) { intellectualAssetPatentType = DeliverableIntellectualAssetPantentTypeEnum .getValue(asset.getPatentType()).getType(); } } else if (DeliverableIntellectualAssetTypeEnum.getValue(asset.getType()) .equals(DeliverableIntellectualAssetTypeEnum.PVP)) { // PVP isPvp = true; if (asset.getVarietyName() != null && !asset.getVarietyName().isEmpty()) { intellectualAssetPvpVarietyName = asset.getVarietyName(); } if (asset.getStatus() != null && asset.getStatus() != -1) { intellectualAssetPvpStatus = ProjectStatusEnum.getValue(asset.getStatus()) .getStatus(); } if (asset.getCountry() != null && !asset.getCountry().getIsoAlpha2().equals("-1")) { intellectualAssetPvpCountry = asset.getCountry().getName(); } if (asset.getAppRegNumber() != null) { intellectualAssetPvpApplicationNumber = asset.getAppRegNumber() + ""; } if (asset.getBreederCrop() != null && !asset.getBreederCrop().isEmpty()) { intellectualAssetPvpBreederCrop = intellectualAssetPvpVarietyName = asset .getBreederCrop(); } } } if (asset.getTitle() != null && !asset.getTitle().isEmpty()) { intellectualAssetTitle = asset.getTitle(); } if (asset.getDateFilling() != null) { intellectualAssetDateFilling = formatter.format(asset.getDateFilling()); } if (asset.getDateRegistration() != null) { intellectualAssetDateRegistration = formatter.format(asset.getDateRegistration()); } if (asset.getDateExpiry() != null) { intellectualAssetDateExpiry = formatter.format(asset.getDateExpiry()); } if (asset.getAdditionalInformation() != null && !asset.getAdditionalInformation().isEmpty()) { intellectualAssetAdditionalInformation = asset.getAdditionalInformation(); } if (asset.getLink() != null && !asset.getLink().isEmpty()) { intellectualAssetLinkPublished = asset.getLink(); } if (asset.getPublicCommunication() != null && !asset.getPublicCommunication().isEmpty()) { intellectualAssetCommunication = asset.getPublicCommunication(); } } else { hasIntellectualAssetText = "No"; } } } // Participants Boolean hasParticipants = false, isAcademicDegree = false, isRegional = false, isNational = false; String hasParticipantsText = null, participantEvent = null, participantActivityType = null, participantAcademicDegree = null, participantTotalParticipants = null, participantFemales = null, participantType = null, participantGeographicScope = null, participantRegional = null, participantCountries = null; List<DeliverableParticipant> deliverableParticipants = deliverable.getDeliverableParticipants() .stream().filter(c -> c.isActive() && c.getPhase().equals(this.getActualPhase())) .collect(Collectors.toList()); if (deliverableParticipants != null && deliverableParticipants.size() > 0) { DeliverableParticipant participant = deliverableParticipants.get(0); if (participant.getHasParticipants() != null) { hasParticipants = participant.getHasParticipants(); if (participant.getHasParticipants()) { hasParticipantsText = "Yes"; if (participant.getEventActivityName() != null && !participant.getEventActivityName().isEmpty()) { participantEvent = participant.getEventActivityName(); } if (participant.getRepIndTypeActivity() != null && participant.getRepIndTypeActivity().getId() != -1) { participantActivityType = participant.getRepIndTypeActivity().getName(); if (participant.getRepIndTypeActivity().getId() .equals(this.getReportingIndTypeActivityAcademicDegree())) { isAcademicDegree = true; participantAcademicDegree = participant.getAcademicDegree(); } } if (participant.getParticipants() != null) { participantTotalParticipants = participant.getParticipants() + ""; } if (participant.getFemales() != null) { participantFemales = participant.getFemales() + ""; } if (participant.getRepIndTypeParticipant() != null && participant.getRepIndTypeParticipant().getId() != -1) { participantType = participant.getRepIndTypeParticipant().getName(); } if (participant.getRepIndGeographicScope() != null && participant.getRepIndGeographicScope().getId() != -1) { participantGeographicScope = participant.getRepIndGeographicScope().getName(); // Regional if (participant.getRepIndGeographicScope().getId() .equals(this.getReportingIndGeographicScopeRegional())) { isRegional = true; if (participant.getRepIndRegion() != null && participant.getRepIndRegion().getId() != -1) { participantRegional = participant.getRepIndRegion().getName(); } } // National/Sub-national/Multinational if (!participant.getRepIndGeographicScope().getId() .equals(this.getReportingIndGeographicScopeGlobal()) && !participant.getRepIndGeographicScope().getId() .equals(this.getReportingIndGeographicScopeRegional())) { isNational = true; List<DeliverableParticipantLocation> locations = participant .getDeliverableParticipantLocations().stream() .filter(pl -> pl.isActive()).collect(Collectors.toList()); if (locations != null && locations.size() > 0) { locations.sort((pl1, pl2) -> pl1.getLocElement().getName() .compareTo(pl2.getLocElement().getName())); Set<String> countries = new HashSet<String>(); for (DeliverableParticipantLocation participantLocation : locations) { countries.add(participantLocation.getLocElement().getName()); } participantCountries = String.join(", ", countries); } } } } else { hasParticipantsText = "No"; } } } // Metadata String titleMetadata = null; String descriptionMetadata = null; String dateMetadata = null; String languageMetadata = null; String countryMetadata = null; String keywordsMetadata = null; String citationMetadata = null; String HandleMetadata = null; String DOIMetadata = null; for (DeliverableMetadataElement deliverableMetadataElement : deliverable .getDeliverableMetadataElements().stream() .filter(dm -> dm.isActive() && dm.getMetadataElement() != null) .collect(Collectors.toList())) { if (deliverableMetadataElement.getMetadataElement().getId() == 1) { if (deliverableMetadataElement.getElementValue() != null && !deliverableMetadataElement.getElementValue().isEmpty()) { titleMetadata = deliverableMetadataElement.getElementValue(); } } if (deliverableMetadataElement.getMetadataElement().getId() == 8) { if (deliverableMetadataElement.getElementValue() != null && !deliverableMetadataElement.getElementValue().isEmpty()) { descriptionMetadata = deliverableMetadataElement.getElementValue(); } } if (deliverableMetadataElement.getMetadataElement().getId() == 17) { if (deliverableMetadataElement.getElementValue() != null && !deliverableMetadataElement.getElementValue().isEmpty()) { dateMetadata = deliverableMetadataElement.getElementValue(); } } if (deliverableMetadataElement.getMetadataElement().getId() == 24) { if (deliverableMetadataElement.getElementValue() != null && !deliverableMetadataElement.getElementValue().isEmpty()) { languageMetadata = deliverableMetadataElement.getElementValue(); } } if (deliverableMetadataElement.getMetadataElement().getId() == 28) { if (deliverableMetadataElement.getElementValue() != null && !deliverableMetadataElement.getElementValue().isEmpty()) { countryMetadata = deliverableMetadataElement.getElementValue(); } } if (deliverableMetadataElement.getMetadataElement().getId() == 37) { if (deliverableMetadataElement.getElementValue() != null && !deliverableMetadataElement.getElementValue().isEmpty()) { keywordsMetadata = deliverableMetadataElement.getElementValue(); } } if (deliverableMetadataElement.getMetadataElement().getId() == 22) { if (deliverableMetadataElement.getElementValue() != null && !deliverableMetadataElement.getElementValue().isEmpty()) { citationMetadata = deliverableMetadataElement.getElementValue(); } } if (deliverableMetadataElement.getMetadataElement().getId() == 35) { if (deliverableMetadataElement.getElementValue() != null && !deliverableMetadataElement.getElementValue().isEmpty()) { HandleMetadata = deliverableMetadataElement.getElementValue(); } } if (deliverableMetadataElement.getMetadataElement().getId() == 36) { if (deliverableMetadataElement.getElementValue() != null && !deliverableMetadataElement.getElementValue().isEmpty()) { DOIMetadata = deliverableMetadataElement.getElementValue(); } } } String creatorAuthors = ""; for (DeliverableUser deliverableUser : deliverable.getDeliverableUsers().stream() .filter(du -> du.isActive()).collect(Collectors.toList())) { creatorAuthors += "<br>? "; if (!deliverableUser.getLastName().isEmpty()) { creatorAuthors += deliverableUser.getLastName() + " - "; } if (!deliverableUser.getFirstName().isEmpty()) { creatorAuthors += deliverableUser.getFirstName(); } if (!deliverableUser.getElementId().isEmpty()) { creatorAuthors += "<" + deliverableUser.getElementId() + ">"; } } if (creatorAuthors.isEmpty()) { creatorAuthors = null; } String dataSharing = ""; for (DeliverableDataSharingFile deliverableDataSharingFile : deliverable .getDeliverableDataSharingFiles().stream().filter(ds -> ds.isActive()) .collect(Collectors.toList())) { if (deliverableDataSharingFile.getExternalFile() != null && !deliverableDataSharingFile.getExternalFile().isEmpty()) { dataSharing += deliverableDataSharingFile.getExternalFile().replace(" ", "%20") + "<br>"; } if (deliverableDataSharingFile.getFile() != null && deliverableDataSharingFile.getFile().isActive()) { dataSharing += (this.getDeliverableDataSharingFilePath() + deliverableDataSharingFile.getFile().getFileName()).replace(" ", "%20") + "<br>"; } } if (dataSharing.isEmpty()) { dataSharing = null; } String qualityAssurance = ""; String dataDictionary = ""; String tools = ""; if (deliverable.getDeliverableQualityChecks().stream().filter(qc -> qc.isActive()) .collect(Collectors.toList()).size() > 0 && deliverable.getDeliverableQualityChecks().stream().filter(qc -> qc.isActive()) .collect(Collectors.toList()).get(0) != null) { DeliverableQualityCheck deliverableQualityCheck = deliverable.getDeliverableQualityChecks() .stream().filter(qc -> qc.isActive()).collect(Collectors.toList()).get(0); // QualityAssurance if (deliverableQualityCheck.getQualityAssurance() != null) { if (deliverableQualityCheck.getQualityAssurance().getId() == 2) { if (deliverableQualityCheck.getFileAssurance() != null && deliverableQualityCheck.getFileAssurance().isActive()) { qualityAssurance += "<br>? File: <font size=2 face='Segoe UI' color='blue'>" + (this.getDeliverableUrl("Assurance", deliverable) + deliverableQualityCheck.getFileAssurance().getFileName()) .replace(" ", "%20") + "</font>"; } if (deliverableQualityCheck.getLinkAssurance() != null && !deliverableQualityCheck.getLinkAssurance().isEmpty()) { qualityAssurance += "<br>? Link: <font size=2 face='Segoe UI' color='blue'>" + deliverableQualityCheck.getLinkAssurance().replace(" ", "%20") + "</font>"; } } else { qualityAssurance = "? " + deliverableQualityCheck.getQualityAssurance().getName(); } } // Data dictionary if (deliverableQualityCheck.getDataDictionary() != null) { if (deliverableQualityCheck.getDataDictionary().getId() == 2) { if (deliverableQualityCheck.getFileDictionary() != null && deliverableQualityCheck.getFileDictionary().isActive()) { dataDictionary += "<br>? File: <font size=2 face='Segoe UI' color='blue'>" + (this.getDeliverableUrl("Dictionary", deliverable) + deliverableQualityCheck.getFileDictionary().getFileName()) .replace(" ", "%20") + "</font>"; } if (deliverableQualityCheck.getLinkDictionary() != null && !deliverableQualityCheck.getLinkDictionary().isEmpty()) { dataDictionary += "<br>? Link: <font size=2 face='Segoe UI' color='blue'>" + deliverableQualityCheck.getLinkDictionary().replace(" ", "%20") + "</font>"; } } else { dataDictionary = "? " + deliverableQualityCheck.getDataDictionary().getName(); } } // Tools if (deliverableQualityCheck.getDataTools() != null) { if (deliverableQualityCheck.getDataTools().getId() == 2) { if (deliverableQualityCheck.getFileTools() != null && deliverableQualityCheck.getFileTools().isActive()) { tools += "<br>? File: <font size=2 face='Segoe UI' color='blue'>" + (this.getDeliverableUrl("Tools", deliverable) + deliverableQualityCheck.getFileTools().getFileName()).replace(" ", "%20") + "</font>"; } if (deliverableQualityCheck.getLinkTools() != null && !deliverableQualityCheck.getLinkTools().isEmpty()) { tools += "<br>? Link: <font size=2 face='Segoe UI' color='blue'>" + deliverableQualityCheck.getLinkTools().replace(" ", "%20") + "</font>"; } } else { tools = "? " + deliverableQualityCheck.getDataTools().getName(); } } } if (qualityAssurance.isEmpty()) { qualityAssurance = null; } if (dataDictionary.isEmpty()) { dataDictionary = null; } if (tools.isEmpty()) { tools = null; } // FAIR String F = ""; if (this.isF(deliverable.getId()) == null) { F = "#cccccc"; } else { if (this.isF(deliverable.getId()) == true) { F = "#8ea786"; } else { F = "#D32F2F"; } } String A = ""; if (this.isA(deliverable.getId()) == null) { A += "#cccccc"; } else { if (this.isA(deliverable.getId()) == true) { A += "#8ea786"; } else { A += "#D32F2F"; } } String I = ""; if (this.isI(deliverable.getId()) == null) { I += "#cccccc"; } else { if (this.isI(deliverable.getId()) == true) { I += "#8ea786"; } else { I += "#D32F2F"; } } String R = ""; if (this.isR(deliverable.getId()) == null) { R += "#cccccc"; } else { if (this.isR(deliverable.getId()) == true) { R += "#8ea786"; } else { R += "#D32F2F"; } } String volume = null; String issue = null; String pages = null; String journal = null; String journalIndicators = ""; String acknowledge = null; String flContrib = ""; // Publication metadata // Verify if the deliverable is of type Articles and Books if (deliverable.getDeliverablePublicationMetadatas().stream().filter(dpm -> dpm.isActive()) .collect(Collectors.toList()).size() > 0 && deliverable.getDeliverablePublicationMetadatas().stream().filter(dpm -> dpm.isActive()) .collect(Collectors.toList()).get(0) != null) { DeliverablePublicationMetadata deliverablePublicationMetadata = deliverable .getDeliverablePublicationMetadatas().stream().filter(dpm -> dpm.isActive()) .collect(Collectors.toList()).get(0); volume = deliverablePublicationMetadata.getVolume(); issue = deliverablePublicationMetadata.getIssue(); pages = deliverablePublicationMetadata.getPages(); journal = deliverablePublicationMetadata.getJournal(); if (deliverablePublicationMetadata.getIsiPublication() != null && deliverablePublicationMetadata.getIsiPublication() == true) { journalIndicators += "? This journal article is an ISI publication <br>"; } if (deliverablePublicationMetadata.getNasr() != null && deliverablePublicationMetadata.getNasr() == true) { journalIndicators += "? This article have a co-author from a developing country National Agricultural Research System (NARS)<br>"; } if (deliverablePublicationMetadata.getCoAuthor() != null && deliverablePublicationMetadata.getCoAuthor() == true) { journalIndicators += "? This article have a co-author based in an Earth System Science-related academic department"; } if (journalIndicators.isEmpty()) { journalIndicators = null; } if (deliverablePublicationMetadata.getPublicationAcknowledge() != null && deliverablePublicationMetadata.getPublicationAcknowledge() == true) { acknowledge = "Yes"; } else { acknowledge = "No"; } List<DeliverableCrp> deliverableCrps = deliverable.getDeliverableCrps().stream() .filter(dc -> dc.isActive() && dc.getPhase() != null && dc.getPhase().equals(this.getSelectedPhase()) && dc.getGlobalUnit() != null) .collect(Collectors.toList()); List<DeliverableCrp> deliverableFlagships = deliverable.getDeliverableCrps().stream() .filter(dc -> dc.isActive() && dc.getPhase() != null && dc.getPhase().equals(this.getSelectedPhase()) && dc.getCrpProgram() != null) .collect(Collectors.toList()); // Crps for (DeliverableCrp deliverableCrp : deliverableCrps) { if (deliverableCrp.getGlobalUnit() != null) { flContrib += "<br> ? " + deliverableCrp.getGlobalUnit().getComposedName(); } } // Flagships for (DeliverableCrp deliverableFlagship : deliverableFlagships) { if (deliverableFlagship.getCrpProgram() != null) { flContrib += "<br> ? " + deliverableFlagship.getCrpProgram().getComposedName(); } } } model.addRow(new Object[] { deliverable.getId(), deliverable.getDeliverableInfo().getTitle(), delivType, delivSubType, delivStatus, delivYear, keyOutput, leader, institution, fundingSources, crossCutting, delivNewYear, delivNewYearJustification, delivDisseminationChannel, delivDisseminationUrl, delivOpenAccess, delivLicense, titleMetadata, descriptionMetadata, dateMetadata, languageMetadata, countryMetadata, keywordsMetadata, citationMetadata, HandleMetadata, DOIMetadata, creatorAuthors, dataSharing, qualityAssurance, dataDictionary, tools, showFAIR, F, A, I, R, isDisseminated, disseminated, restrictedAccess, isRestricted, restrictedDate, isLastTwoRestricted, delivLicenseModifications, showDelivLicenseModifications, volume, issue, pages, journal, journalIndicators, acknowledge, flContrib, showPublication, showCompilance, deliv_description, hasIntellectualAsset, isPantent, isPvp, hasParticipants, isAcademicDegree, isRegional, isNational, hasParticipantsText, participantEvent, participantActivityType, participantAcademicDegree, participantTotalParticipants, participantFemales, participantType, participantGeographicScope, participantRegional, participantCountries, hasIntellectualAssetText, intellectualAssetApplicants, intellectualAssetType, intellectualAssetTitle, intellectualAssetFillingType, intellectualAssetPantentStatus, intellectualAssetPatentType, intellectualAssetPvpVarietyName, intellectualAssetPvpStatus, intellectualAssetPvpCountry, intellectualAssetPvpApplicationNumber, intellectualAssetPvpBreederCrop, intellectualAssetDateFilling, intellectualAssetDateRegistration, intellectualAssetDateExpiry, intellectualAssetAdditionalInformation, intellectualAssetLinkPublished, intellectualAssetCommunication }); } } return model; }