Example usage for java.util LinkedHashSet isEmpty

List of usage examples for java.util LinkedHashSet isEmpty

Introduction

In this page you can find the example usage for java.util LinkedHashSet isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:com.geewhiz.pacify.filter.PacifyVelocityFilter.java

@Override
public LinkedHashSet<Defect> filter(PFile pFile, Map<String, String> propertyValues) {
    LinkedHashSet<Defect> defects = new LinkedHashSet<Defect>();

    if (!BEGIN_TOKEN.equals(pFile.getBeginToken())) {
        defects.add(new WrongTokenDefinedDefect(pFile, "If you use the PacifyVelocityFilter class, only \""
                + BEGIN_TOKEN + "\" is allowed as start token."));
    }// w  w w .ja v a2 s .  c o  m

    if (!END_TOKEN.equals(pFile.getEndToken())) {
        defects.add(new WrongTokenDefinedDefect(pFile, "If you use the PacifyVelocityFilter class, only \""
                + END_TOKEN + "\" is allowed as end token."));
    }

    if (!defects.isEmpty()) {
        return defects;
    }

    File fileToFilter = pFile.getFile();
    File tmpFile = FileUtils.createEmptyFileWithSamePermissions(fileToFilter);

    Template template = getTemplate(fileToFilter, pFile.getEncoding());
    Context context = getContext(propertyValues, fileToFilter);

    try {
        FileWriterWithEncoding fw = new FileWriterWithEncoding(tmpFile, pFile.getEncoding());
        template.merge(context, fw);
        fw.close();
        if (!fileToFilter.delete()) {
            throw new RuntimeException("Couldn't delete file [" + fileToFilter.getPath() + "]... Aborting!");
        }
        if (!tmpFile.renameTo(fileToFilter)) {
            throw new RuntimeException("Couldn't rename filtered file from [" + tmpFile.getPath() + "] to ["
                    + fileToFilter.getPath() + "]... Aborting!");
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return defects;
}

From source file:com.hp.autonomy.searchcomponents.idol.parametricvalues.IdolParametricValuesService.java

@Override
public Set<QueryTagInfo> getAllParametricValues(final IdolParametricRequest parametricRequest)
        throws AciErrorException {
    final Collection<String> fieldNames = new HashSet<>();
    fieldNames.addAll(parametricRequest.getFieldNames());
    if (fieldNames.isEmpty()) {
        fieldNames.addAll(fieldsService.getParametricFields(new IdolFieldsRequest.Builder().build()));
    }/*from  w  w  w. j a  v  a  2s . c o m*/

    final Set<QueryTagInfo> results;
    if (fieldNames.isEmpty()) {
        results = Collections.emptySet();
    } else {
        final AciParameters aciParameters = new AciParameters(TagActions.GetQueryTagValues.name());
        parameterHandler.addSearchRestrictions(aciParameters, parametricRequest.getQueryRestrictions());

        if (parametricRequest.isModified()) {
            parameterHandler.addQmsParameters(aciParameters, parametricRequest.getQueryRestrictions());
        }

        aciParameters.add(GetQueryTagValuesParams.DocumentCount.name(), true);
        aciParameters.add(GetQueryTagValuesParams.MaxValues.name(), parametricRequest.getMaxValues());
        aciParameters.add(GetQueryTagValuesParams.FieldName.name(),
                StringUtils.join(fieldNames.toArray(), ','));
        aciParameters.add(GetQueryTagValuesParams.Sort.name(), SortParam.DocumentCount.name());

        final GetQueryTagValuesResponseData responseData = contentAciService.executeAction(aciParameters,
                queryTagValuesResponseProcessor);
        final List<FlatField> fields = responseData.getField();
        results = new LinkedHashSet<>(fields.size());
        for (final FlatField field : fields) {
            final List<JAXBElement<? extends Serializable>> valueElements = field.getValueOrSubvalueOrValues();
            final LinkedHashSet<QueryTagCountInfo> values = new LinkedHashSet<>(valueElements.size());
            for (final JAXBElement<?> element : valueElements) {
                if (VALUE_NODE_NAME.equals(element.getName().getLocalPart())) {
                    final TagValue tagValue = (TagValue) element.getValue();
                    values.add(new QueryTagCountInfo(tagValue.getValue(), tagValue.getCount()));
                }
            }
            final String fieldName = getFieldNameFromPath(field.getName().get(0));
            if (!values.isEmpty()) {
                results.add(new QueryTagInfo(fieldName, values));
            }
        }
    }

    return results;
}

From source file:net.sf.taverna.t2.activities.beanshell.BeanshellActivityHealthChecker.java

public VisitReport visit(BeanshellActivity activity, List<Object> ancestors) {
    Object subject = (Processor) VisitReport.findAncestor(ancestors, Processor.class);
    if (subject == null) {
        // Fall back to using the activity itself as the subject of the reports
        subject = activity;//from  w  ww.ja  v  a  2  s.co  m
    }
    List<VisitReport> reports = new ArrayList<VisitReport>();

    String script = activity.getConfiguration().get("script").textValue();
    if (!script.trim().endsWith(";")) {
        /** Missing ; on last line is not allowed by Parser,
         * but is allowed by Interpreter.eval() used at runtime
         */
        script = script + ";";
    }
    Parser parser = new Parser(new StringReader(script));
    try {
        while (!parser.Line())
            ;
        reports.add(new VisitReport(HealthCheck.getInstance(), subject, "Script OK", HealthCheck.NO_PROBLEM,
                Status.OK));
    } catch (ParseException e) {
        VisitReport report = new VisitReport(HealthCheck.getInstance(), subject, e.getMessage(),
                HealthCheck.INVALID_SCRIPT, Status.SEVERE);
        report.setProperty("exception", e);
        reports.add(report);
    }

    // Check if we can find all the Beanshell's dependencies
    if (activity.getConfiguration().has("localDependency")) {
        LinkedHashSet<String> localDependencies = new LinkedHashSet<>();
        for (JsonNode localDependency : activity.getConfiguration().get("localDependency")) {
            localDependencies.add(localDependency.textValue());
        }

        String[] jarArray = activity.libDir.list(new FileExtFilter(".jar"));
        if (jarArray != null) {
            List<String> jarFiles = Arrays.asList(jarArray); // URLs of all jars found in the lib directory
            for (String jar : localDependencies) {
                if (jarFiles.contains(jar)) {
                    localDependencies.remove(jar);
                }
            }
        }
        if (localDependencies.isEmpty()) { // all dependencies found
            reports.add(new VisitReport(HealthCheck.getInstance(), subject, "Beanshell dependencies found",
                    HealthCheck.NO_PROBLEM, Status.OK));
        } else {
            VisitReport vr = new VisitReport(HealthCheck.getInstance(), subject,
                    "Beanshell dependencies missing", HealthCheck.MISSING_DEPENDENCY, Status.SEVERE);
            vr.setProperty("dependencies", localDependencies);
            vr.setProperty("directory", activity.libDir);
            reports.add(vr);
        }

    }
    Status status = VisitReport.getWorstStatus(reports);
    VisitReport report = new VisitReport(HealthCheck.getInstance(), subject, "Beanshell report",
            HealthCheck.NO_PROBLEM, status, reports);

    return report;

}

From source file:com.geewhiz.pacify.managers.FilterManager.java

public LinkedHashSet<Defect> doFilter() {
    LinkedHashSet<Defect> defects = new LinkedHashSet<Defect>();

    for (Object entry : pMarker.getFilesAndArchives()) {
        if (entry instanceof PFile) {
            defects.addAll(filterPFile((PFile) entry));
        } else if (entry instanceof PArchive) {
            defects.addAll(filterPArchive((PArchive) entry));
        } else {/*from  ww  w.  j  a  v a 2 s  .c  o  m*/
            throw new NotImplementedException(
                    "Filter implementation for " + entry.getClass().getName() + " not implemented.");
        }
    }

    CheckForNotReplacedTokens checker = new CheckForNotReplacedTokens();
    defects.addAll(checker.checkForErrors(pMarker));

    if (defects.isEmpty()) {
        pMarker.getFile().delete();
    }

    return defects;
}

From source file:com.qwazr.server.configuration.ServerConfiguration.java

protected ServerConfiguration(final Map<?, ?>... propertiesMaps) throws IOException {

    // Merge the maps.
    properties = new HashMap<>();
    if (propertiesMaps != null) {
        for (Map<?, ?> props : propertiesMaps)
            if (props != null)
                props.forEach((key, value) -> {
                    if (key != null && value != null)
                        properties.put(key.toString(), value.toString());
                });//  w  ww.  ja  va  2  s. co  m
    }

    //Set the data directory
    dataDirectory = getDataDirectory(getStringProperty(QWAZR_DATA, null));
    if (dataDirectory == null)
        throw new IOException("The data directory has not been set.");
    if (!Files.exists(dataDirectory))
        throw new IOException("The data directory does not exists: " + dataDirectory.toAbsolutePath());
    if (!Files.isDirectory(dataDirectory))
        throw new IOException("The data directory is not a directory: " + dataDirectory.toAbsolutePath());

    //Set the temp directory
    tempDirectory = getTempDirectory(dataDirectory, getStringProperty(QWAZR_TEMP, null));
    if (!Files.exists(tempDirectory))
        Files.createDirectories(tempDirectory);
    if (!Files.exists(tempDirectory))
        throw new IOException("The temp directory does not exists: " + tempDirectory.toAbsolutePath());
    if (!Files.isDirectory(tempDirectory))
        throw new IOException("The temp directory is not a directory: " + tempDirectory.toAbsolutePath());

    //Set the configuration directories
    etcDirectories = getEtcDirectories(getStringProperty(QWAZR_ETC_DIR, null));
    etcFileFilter = buildEtcFileFilter(getStringProperty(QWAZR_ETC, null));

    //Set the listen address
    listenAddress = findListenAddress(getStringProperty(LISTEN_ADDR, null));

    //Set the public address
    publicAddress = findPublicAddress(getStringProperty(PUBLIC_ADDR, null), this.listenAddress);

    //Set the connectors
    webAppConnector = new WebConnector(publicAddress, getIntegerProperty(WEBAPP_PORT, null), 9090,
            getStringProperty(WEBAPP_AUTHENTICATION, null), getStringProperty(WEBAPP_REALM, null));
    webServiceConnector = new WebConnector(publicAddress, getIntegerProperty(WEBSERVICE_PORT, null), 9091,
            getStringProperty(WEBSERVICE_AUTHENTICATION, null), getStringProperty(WEBSERVICE_REALM, null));
    multicastConnector = new WebConnector(getStringProperty(MULTICAST_ADDR, null),
            getIntegerProperty(MULTICAST_PORT, null), 9091, null, null);

    // Collect the master address.
    final LinkedHashSet<String> set = new LinkedHashSet<>();
    try {
        findMatchingAddress(getStringProperty(QWAZR_MASTERS, null), set);
    } catch (SocketException e) {
        LOGGER.warning("Failed in extracting IP information. No master server is configured.");
    }
    this.masters = set.isEmpty() ? null : Collections.unmodifiableSet(set);

    this.groups = buildSet(getStringProperty(QWAZR_GROUPS, null), ",; \t", true);
}

From source file:cz.incad.kramerius.pdf.impl.FirstPagePDFServiceImpl.java

String templateParent(PreparedDocument rdoc, ObjectPidsPath path) throws IOException,
        ParserConfigurationException, SAXException, XPathExpressionException, JAXBException {
    ResourceBundle resourceBundle = resourceBundleService.getResourceBundle("base", localesProvider.get());

    StringTemplate template = new StringTemplate(IOUtils.readAsString(
            this.getClass().getResourceAsStream("templates/_first_page.st"), Charset.forName("UTF-8"), true));
    FirstPageViewObject fpvo = prepareViewObject(resourceBundle);

    // tistena polozka
    GeneratedItem itm = new GeneratedItem();

    // detaily/*from   w ww  . j  a  v a 2  s  .c o  m*/
    Map<String, LinkedHashSet<String>> detailItemValues = new HashMap<String, LinkedHashSet<String>>();
    Map<String, Map<String, List<String>>> mods = processModsFromPath(path, null);

    // Hlavni nazev
    String rootPid = path.getRoot();
    if (mods.get(rootPid).containsKey(TitleBuilder.MODS_TITLE)) {
        List<String> list = mods.get(rootPid).get(TitleBuilder.MODS_TITLE);
        if (!list.isEmpty()) {
            String key = TitleBuilder.MODS_TITLE;
            itemVals(detailItemValues, list, key);
        }
    }

    // pouze jeden root
    String[] rProps = renderedProperties(true);
    String[] fromRootToLeaf = path.getPathFromRootToLeaf();
    for (int i = 0; i < fromRootToLeaf.length; i++) {
        String pidPath = fromRootToLeaf[i];
        for (String prop : rProps) {

            if (mods.get(pidPath).containsKey(prop)) {
                List<String> list = mods.get(pidPath).get(prop);
                itemVals(detailItemValues, list, prop);
            }
        }
    }

    // hlavni nazev
    List<DetailItem> details = new ArrayList<FirstPagePDFServiceImpl.DetailItem>();
    LinkedHashSet<String> maintitles = detailItemValues.get(TitleBuilder.MODS_TITLE);
    String key = maintitles != null && maintitles.size() > 1 ? resourceBundle.getString("pdf.fp.titles")
            : resourceBundle.getString("pdf.fp.title");
    if (maintitles != null && (!maintitles.isEmpty())) {
        details.add(new DetailItem(key, vals(maintitles).toString()));
    }

    String[] props = renderedProperties(true);
    for (String prop : props) {
        LinkedHashSet<String> vals = detailItemValues.get(prop);
        key = vals != null && vals.size() > 1 ? resourceBundle.getString(i18nKey(prop) + "s")
                : resourceBundle.getString(i18nKey(prop));
        if (vals != null && (!vals.isEmpty())) {
            details.add(new DetailItem(key, vals(vals).toString()));
        }
    }

    pagesInParentPdf(rdoc, resourceBundle, details);

    itm.setDetailItems((DetailItem[]) details.toArray(new DetailItem[details.size()]));

    fpvo.setGeneratedItems(new GeneratedItem[] { itm });
    template.setAttribute("viewinfo", fpvo);
    String templateText = template.toString();
    return templateText;
}

From source file:cz.incad.kramerius.pdf.impl.FirstPagePDFServiceImpl.java

String templateSelection(PreparedDocument rdoc, String... pids)
        throws XPathExpressionException, IOException, ParserConfigurationException, SAXException {
    ResourceBundle resourceBundle = resourceBundleService.getResourceBundle("base", localesProvider.get());

    StringTemplate template = new StringTemplate(IOUtils.readAsString(
            this.getClass().getResourceAsStream("templates/_first_page.st"), Charset.forName("UTF-8"), true));
    FirstPageViewObject fpvo = prepareViewObject(resourceBundle);

    // tistena polozka
    GeneratedItem itm = new GeneratedItem();

    Map<String, LinkedHashSet<String>> detailItemValues = new HashMap<String, LinkedHashSet<String>>();
    Map<String, ObjectPidsPath> pathsMapping = new HashMap<String, ObjectPidsPath>();
    LinkedHashSet<String> roots = new LinkedHashSet<String>();
    for (String pid : pids) {
        ObjectPidsPath sPath = selectOnePath(pid);
        pathsMapping.put(pid, sPath);//from   w  ww  . j  a  va 2s.com
        roots.add(sPath.getRoot());
    }

    for (String pid : pids) {
        ObjectPidsPath path = pathsMapping.get(pid);
        Map<String, Map<String, List<String>>> mods = processModsFromPath(path, null);
        String rootPid = path.getRoot();
        if (mods.get(rootPid).containsKey(TitleBuilder.MODS_TITLE)) {
            List<String> list = mods.get(rootPid).get(TitleBuilder.MODS_TITLE);
            if (!list.isEmpty()) {
                String key = TitleBuilder.MODS_TITLE;
                itemVals(detailItemValues, list, key);
            }
        }

        String[] rProps = renderedProperties(roots.size() == 1);
        String[] fromRootToLeaf = path.getPathFromRootToLeaf();
        for (int i = 0; i < fromRootToLeaf.length; i++) {
            String pidPath = fromRootToLeaf[i];
            for (String prop : rProps) {

                if (mods.get(pidPath).containsKey(prop)) {
                    List<String> list = mods.get(pidPath).get(prop);
                    itemVals(detailItemValues, list, prop);
                }
            }
        }
    }

    // hlavni nazev
    List<DetailItem> details = new ArrayList<FirstPagePDFServiceImpl.DetailItem>();
    LinkedHashSet<String> maintitles = detailItemValues.get(TitleBuilder.MODS_TITLE);
    String key = maintitles != null && maintitles.size() > 1 ? resourceBundle.getString("pdf.fp.titles")
            : resourceBundle.getString("pdf.fp.title");
    if (maintitles != null && (!maintitles.isEmpty())) {
        details.add(new DetailItem(key, vals(maintitles).toString()));
    }

    for (String prop : renderedProperties(roots.size() == 1)) {
        LinkedHashSet<String> vals = detailItemValues.get(prop);
        key = vals != null && vals.size() > 1 ? resourceBundle.getString(i18nKey(prop) + "s")
                : resourceBundle.getString(i18nKey(prop));
        if (vals != null && (!vals.isEmpty())) {
            details.add(new DetailItem(key, vals(vals).toString()));
        }
    }

    // stranky v pdfku
    pagesInSelectiontPdf(rdoc, resourceBundle, details);

    itm.setDetailItems((DetailItem[]) details.toArray(new DetailItem[details.size()]));
    fpvo.setGeneratedItems(new GeneratedItem[] { itm });

    template.setAttribute("viewinfo", fpvo);

    String templateText = template.toString();

    return templateText;
}

From source file:org.objectweb.proactive.extensions.dataspaces.vfs.VFSSpacesMountManagerImpl.java

/**
 * Mounts the first available VFS file system on the given dataspace
 * @param spaceInfo space information// ww  w  . j a  va 2 s. c  o  m
 * @throws FileSystemException if no file system could be mounted
 */
private void mountFirstAvailableFileSystem(final SpaceInstanceInfo spaceInfo) throws FileSystemException {

    final DataSpacesURI mountingPoint = spaceInfo.getMountingPoint();

    try {
        writeLock.lock();
        if (!mountedSpaces.containsKey(mountingPoint)) {
            mountedSpaces.put(mountingPoint, new ConcurrentHashMap<String, FileObject>());
        }
        ConcurrentHashMap<String, FileObject> fileSystems = mountedSpaces.get(mountingPoint);

        if (spaceInfo.getUrls().size() == 0) {
            throw new IllegalStateException("Empty Space configuration");
        }

        DataSpacesURI spacePart = mountingPoint.getSpacePartOnly();
        ArrayList<String> urls = new ArrayList<String>(spaceInfo.getUrls());
        if (urls.size() == 1) {
            urls.add(0, Utils.getLocalAccessURL(urls.get(0), spaceInfo.getPath(), spaceInfo.getHostname()));
        }

        logger.debug("[VFSMountManager] Request mounting VFS root list : " + urls);

        try {
            VFSMountManagerHelper.mountAny(urls, fileSystems);

            if (!accessibleFileObjectUris.containsKey(mountingPoint)) {
                LinkedHashSet<String> srl = new LinkedHashSet<String>();
                accessibleFileObjectUris.put(mountingPoint, srl);
            }

            LinkedHashSet<String> srl = accessibleFileObjectUris.get(mountingPoint);

            for (String uri : urls) {
                if (fileSystems.containsKey(uri)) {
                    srl.add(uri);
                }
            }
            if (srl.isEmpty()) {
                throw new IllegalStateException("Invalid empty size list when trying to mount " + urls
                        + " mounted map content is " + fileSystems);
            }
            accessibleFileObjectUris.put(mountingPoint, srl);

            if (logger.isDebugEnabled())
                logger.debug(
                        String.format("[VFSMountManager] Mounted space: %s (access URL: %s)", spacePart, srl));

            mountedSpaces.put(mountingPoint, fileSystems);

        } catch (org.apache.commons.vfs.FileSystemException e) {
            mountedSpaces.remove(mountingPoint);
            throw new FileSystemException("An error occurred while trying to mount " + spaceInfo.getName(), e);
        }
    } finally {
        writeLock.unlock();
    }
}

From source file:org.mskcc.cbio.oncokb.quest.VariantAnnotationXML.java

public static String annotate(Alteration alt, String tumorType) {
        //        GeneBo geneBo = ApplicationContextSingleton.getGeneBo();

        StringBuilder sb = new StringBuilder();

        Gene gene = alt.getGene();//from  w w w . j a  va2 s  .  c o  m

        //        Set<Gene> genes = new HashSet<Gene>();
        //        if (gene.getEntrezGeneId() > 0) {
        //            genes.add(gene);
        //        } else {
        // fake gene... could be a fusion gene
        //            Set<String> aliases = gene.getGeneAliases();
        //            for (String alias : aliases) {
        //                Gene g = geneBo.findGeneByHugoSymbol(alias);
        //                if (g != null) {
        //                    genes.add(g);
        //                }
        //            }
        //        }

        List<TumorType> relevantTumorTypes = TumorTypeUtils.getMappedOncoTreeTypesBySource(tumorType, "quest");

        AlterationUtils.annotateAlteration(alt, alt.getAlteration());

        AlterationBo alterationBo = ApplicationContextSingleton.getAlterationBo();
        LinkedHashSet<Alteration> alterations = alterationBo.findRelevantAlterations(alt, true);

        // In previous logic, we do not include alternative alleles
        List<Alteration> alternativeAlleles = AlterationUtils.getAlleleAlterations(alt);
        alterations.removeAll(alternativeAlleles);

        EvidenceBo evidenceBo = ApplicationContextSingleton.getEvidenceBo();

        // find all drugs
        //List<Drug> drugs = evidenceBo.findDrugsByAlterations(alterations);

        // find tumor types
        Set<String> tumorTypes = new HashSet<>();

        if (alterations != null && alterations.size() > 0) {
            List<Object> tumorTypesEvidence = evidenceBo
                    .findTumorTypesWithEvidencesForAlterations(new ArrayList<>(alterations));
            for (Object evidence : tumorTypesEvidence) {
                if (evidence != null) {
                    Object[] evidences = (Object[]) evidence;
                    if (evidences.length > 0 && evidences[0] != null) {
                        tumorTypes.add((String) evidences[0]);
                    }
                }
            }
        }

        //        sortTumorType(tumorTypes, tumorType);
        Query query = new Query(alt);
        query.setTumorType(tumorType);
        // summary
        sb.append("<annotation_summary>");
        sb.append(SummaryUtils.fullSummary(gene, alt,
                alterations.isEmpty() ? Collections.singletonList(alt) : new ArrayList<>(alterations), query,
                relevantTumorTypes));
        sb.append("</annotation_summary>\n");

        // gene background
        List<Evidence> geneBgEvs = evidenceBo.findEvidencesByGene(Collections.singleton(gene),
                Collections.singleton(EvidenceType.GENE_BACKGROUND));
        if (!geneBgEvs.isEmpty()) {
            Evidence ev = geneBgEvs.get(0);
            sb.append("<gene_annotation>\n");
            sb.append("    <description>");
            sb.append(StringEscapeUtils.escapeXml10(ev.getDescription()).trim());
            sb.append("</description>\n");
            exportRefereces(ev, sb, "    ");
            sb.append("</gene_annotation>\n");
        }

        if (alterations.isEmpty()) {
            sb.append("<!-- There is no information about the function of this variant in the MSKCC OncoKB. -->");
            return sb.toString();
        }

        List<Evidence> mutationEffectEbs = evidenceBo.findEvidencesByAlteration(alterations,
                Collections.singleton(EvidenceType.MUTATION_EFFECT));
        for (Evidence ev : mutationEffectEbs) {
            sb.append("<variant_effect>\n");
            sb.append("    <effect>");
            if (ev != null) {
                sb.append(ev.getKnownEffect());
            }
            sb.append("</effect>\n");
            if (ev.getDescription() != null) {
                sb.append("    <description>");
                sb.append(StringEscapeUtils.escapeXml10(ev.getDescription()).trim());
                sb.append("</description>\n");
            }
            if (ev != null) {
                exportRefereces(ev, sb, "    ");
            }

            sb.append("</variant_effect>\n");
        }

        for (String tt : tumorTypes) {
            TumorType oncoTreeType = TumorTypeUtils.getMappedOncoTreeTypesBySource(tt, "quest").get(0);
            boolean isRelevant = relevantTumorTypes.contains(oncoTreeType);

            StringBuilder sbTumorType = new StringBuilder();
            sbTumorType.append("<cancer_type type=\"").append(tt).append("\" relevant_to_patient_disease=\"")
                    .append(isRelevant ? "Yes" : "No").append("\">\n");
            int nEmp = sbTumorType.length();

            // find prognostic implication evidence blob
            Set<Evidence> prognosticEbs = new HashSet<Evidence>(evidenceBo.findEvidencesByAlteration(alterations,
                    Collections.singleton(EvidenceType.PROGNOSTIC_IMPLICATION),
                    Collections.singleton(oncoTreeType)));
            if (!prognosticEbs.isEmpty()) {
                sbTumorType.append("    <prognostic_implications>\n");
                sbTumorType.append("        <description>\n");
                for (Evidence ev : prognosticEbs) {
                    String description = ev.getDescription();
                    if (description != null) {
                        sbTumorType.append("        ").append(StringEscapeUtils.escapeXml10(description).trim())
                                .append("\n");
                    }
                }
                sbTumorType.append("</description>\n");

                for (Evidence ev : prognosticEbs) {
                    exportRefereces(ev, sbTumorType, "        ");
                }
                sbTumorType.append("    </prognostic_implications>\n");
            }

            // STANDARD_THERAPEUTIC_IMPLICATIONS
            List<Evidence> stdImpEbsSensitivity = evidenceBo.findEvidencesByAlteration(alterations,
                    Collections.singleton(EvidenceType.STANDARD_THERAPEUTIC_IMPLICATIONS_FOR_DRUG_SENSITIVITY),
                    Collections.singleton(oncoTreeType));
            List<Evidence> stdImpEbsResisitance = evidenceBo.findEvidencesByAlteration(alterations,
                    Collections.singleton(EvidenceType.STANDARD_THERAPEUTIC_IMPLICATIONS_FOR_DRUG_RESISTANCE),
                    Collections.singleton(oncoTreeType));

            //Remove level_0
            stdImpEbsSensitivity = filterLevelZeroEvidence(stdImpEbsSensitivity);

            //Remove level_R3
            stdImpEbsResisitance = filterResistanceEvidence(stdImpEbsResisitance);

            exportTherapeuticImplications(relevantTumorTypes, stdImpEbsSensitivity, stdImpEbsResisitance,
                    "standard_therapeutic_implications", sbTumorType, "    ", isRelevant);

            // INVESTIGATIONAL_THERAPEUTIC_IMPLICATIONS
            List<Evidence> invImpEbsSensitivity = evidenceBo.findEvidencesByAlteration(alterations,
                    Collections.singleton(EvidenceType.INVESTIGATIONAL_THERAPEUTIC_IMPLICATIONS_DRUG_SENSITIVITY),
                    Collections.singleton(oncoTreeType));
            List<Evidence> invImpEbsResisitance = evidenceBo.findEvidencesByAlteration(alterations,
                    Collections.singleton(EvidenceType.INVESTIGATIONAL_THERAPEUTIC_IMPLICATIONS_DRUG_RESISTANCE),
                    Collections.singleton(oncoTreeType));

            //Remove level_R3
            invImpEbsResisitance = filterResistanceEvidence(invImpEbsResisitance);

            exportTherapeuticImplications(relevantTumorTypes, invImpEbsSensitivity, invImpEbsResisitance,
                    "investigational_therapeutic_implications", sbTumorType, "    ", isRelevant);

            if (sbTumorType.length() > nEmp) {
                sbTumorType.append("</cancer_type>\n");
                sb.append(sbTumorType);
            }
        }

        return sb.toString();
    }

From source file:eionet.cr.web.util.columns.ReferringPredicatesColumn.java

@Override
public String format(Object object) {

    if (object instanceof SubjectDTO) {

        SubjectDTO subjectDTO = (SubjectDTO) object;

        // Collect labels of all predicates pointing to referringToHash (ignore derived object values).

        LinkedHashSet<String> labels = new LinkedHashSet<String>();
        Map<String, Collection<ObjectDTO>> predicatesObjects = subjectDTO.getPredicates();
        if (predicatesObjects != null && !predicatesObjects.isEmpty()) {

            for (String predicate : predicatesObjects.keySet()) {

                Collection<ObjectDTO> objects = predicatesObjects.get(predicate);
                if (objects != null && !objects.isEmpty()) {

                    for (ObjectDTO objectDTO : objects) {

                        if (objectDTO.getSourceObjectHash() == 0 && objectDTO.getHash() == referringToHash) {

                            String predicateLabel = JstlFunctions
                                    .getPredicateLabel(actionBean.getPredicateLabels(), predicate);
                            labels.add(predicateLabel);
                        }//  w w w.  j  av  a 2 s.c  o  m
                    }
                }
            }
        }

        // Return the above-found labels as a comma-separated list.
        return labels.isEmpty() ? StringUtils.EMPTY : Util.toCSV(labels);
    } else {
        return object == null ? StringUtils.EMPTY : object.toString();
    }
}