Example usage for java.util TreeSet addAll

List of usage examples for java.util TreeSet addAll

Introduction

In this page you can find the example usage for java.util TreeSet addAll.

Prototype

public boolean addAll(Collection<? extends E> c) 

Source Link

Document

Adds all of the elements in the specified collection to this set.

Usage

From source file:org.apache.hadoop.hbase.backup.impl.RestoreClientImpl.java

/**
 * Restore operation. Stage 2: resolved Backup Image dependency
 * @param backupManifestMap : tableName,  Manifest
 * @param sTableArray The array of tables to be restored
 * @param tTableArray The array of mapping tables to restore to
 * @return set of BackupImages restored//from   ww  w  .j  a  v a  2s  . co  m
 * @throws IOException exception
 */
private void restoreStage(HashMap<TableName, BackupManifest> backupManifestMap, TableName[] sTableArray,
        TableName[] tTableArray, boolean isOverwrite) throws IOException {
    TreeSet<BackupImage> restoreImageSet = new TreeSet<BackupImage>();
    boolean truncateIfExists = isOverwrite;
    try {
        for (int i = 0; i < sTableArray.length; i++) {
            TableName table = sTableArray[i];
            BackupManifest manifest = backupManifestMap.get(table);
            // Get the image list of this backup for restore in time order from old
            // to new.
            List<BackupImage> list = new ArrayList<BackupImage>();
            list.add(manifest.getBackupImage());
            List<BackupImage> depList = manifest.getDependentListByTable(table);
            list.addAll(depList);
            TreeSet<BackupImage> restoreList = new TreeSet<BackupImage>(list);
            LOG.debug("need to clear merged Image. to be implemented in future jira");
            restoreImages(restoreList.iterator(), table, tTableArray[i], truncateIfExists);
            restoreImageSet.addAll(restoreList);

            if (restoreImageSet != null && !restoreImageSet.isEmpty()) {
                LOG.info("Restore includes the following image(s):");
                for (BackupImage image : restoreImageSet) {
                    LOG.info("Backup: " + image.getBackupId() + " " + HBackupFileSystem
                            .getTableBackupDir(image.getRootDir(), image.getBackupId(), table));
                }
            }
        }
    } catch (Exception e) {
        LOG.error("Failed", e);
        throw new IOException(e);
    }
    LOG.debug("restoreStage finished");

}

From source file:org.gvsig.framework.web.service.impl.OGCInfoServiceImpl.java

public WMSInfo getCapabilitiesFromWMS(String urlServerWMS, TreeSet<String> listCrs, String format,
        boolean isCalledByWizard) throws ServerGeoException {
    WMSInfo wmsInfo = new WMSInfo();
    // put url on object WMSInfo
    wmsInfo.setServiceUrl(urlServerWMS);

    // Create hashmap to add the layers getted to the WMSInfo object
    Map<String, org.gvsig.framework.web.ogc.WMSLayer> layersMap = new HashMap<String, org.gvsig.framework.web.ogc.WMSLayer>();

    // Create conexion with server WMS
    try {//  www  .ja v a 2  s.  co m
        WMSClient wms = new WMSClient(urlServerWMS);
        wms.connect(null);

        // set server information
        WMSServiceInformation serviceInfo = wms.getServiceInformation();
        wmsInfo.setServiceAbstract(serviceInfo.abstr);
        wmsInfo.setServiceName(serviceInfo.name);
        wmsInfo.setServiceTitle(serviceInfo.title);

        // set id of the request wmsinfo (service name + calendar)
        int hashCode = (serviceInfo.name + Calendar.getInstance()).hashCode();
        wmsInfo.setId(hashCode);

        // get and set version
        String version = wms.getVersion();
        wmsInfo.setVersion(version);

        // get and set formats
        Vector formatVector = wms.getFormats();
        TreeSet<String> formatSet = new TreeSet<String>();
        formatSet.addAll(formatVector);
        wmsInfo.setFormatsSupported(formatSet);
        if (StringUtils.isEmpty(format)) {
            format = getFirstFormatSupported(formatSet);
            wmsInfo.setFormatSelected(format);
        }
        // check format
        if (isCalledByWizard || (!isCalledByWizard && formatVector.contains(format))) {
            wmsInfo.setFormatSelected(format);
            // get root layer
            WMSLayer rootLayer = wms.getRootLayer();
            // get crs (srs) (belong to layer)
            Vector crsVector = rootLayer.getAllSrs();
            // get and set all common crs supported
            TreeSet<String> crsTreeSet = new TreeSet<String>();
            crsTreeSet.addAll(crsVector);
            wmsInfo.setCrsSupported(crsTreeSet);

            // Create tree with layer values
            List<TreeNode> tree = new ArrayList<TreeNode>();

            // Create root node
            ArrayList<WMSLayer> children = rootLayer.getChildren();
            TreeNode rootNode = new TreeNode("rootLayer_" + rootLayer.getName());
            rootNode.setTitle(rootLayer.getTitle());
            if (children.isEmpty()) {
                rootNode.setFolder(false);
            } else {
                rootNode.setFolder(true);
                rootNode.setExpanded(true);
                generateWMSChildrenNodes(children, tree, listCrs, rootNode, layersMap, wmsInfo);
            }

            // Set childrenLayers paramrootLayer.getChildren()
            wmsInfo.setChildrenCount(children.size());

            // Only register the tree if it has a layer with crs defined
            if (rootNode.hasChildren()) {
                tree.add(rootNode);
                wmsInfo.setLayersTree(tree);
            }

            TreeSet<String> selCrs = new TreeSet<String>();
            if (listCrs.isEmpty()) {
                selCrs.addAll(wmsInfo.getCrsSupported());
            } else {
                selCrs.addAll(CollectionUtils.intersection(listCrs, wmsInfo.getCrsSupported()));

            }
            wmsInfo.setCrsSelected(selCrs);

            // Add map that contains info of all layers
            wmsInfo.setLayers(layersMap);
        }
    } catch (Exception exc) {
        // Show exception in log and create ServerGeoException which is
        // captured on controller and puts message to ajax response
        logger.error("Exception on getCapabilitiesFromWMS", exc);
        throw new ServerGeoException();
    }

    return wmsInfo;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.administrativeOffice.scholarship.utl.report.StudentLine.java

public LocalDate getFirstEnrolmentOnCurrentExecutionYear() {
    if (getRegistration() == null) {
        return null;
    }//from w w w.  j  a  v  a 2 s.  c o  m

    if (getRegistration().isInMobilityState()) {
        return getForExecutionYear().getBeginDateYearMonthDay().toLocalDate();
    }

    TreeSet<Enrolment> orderedEnrolmentSet = new TreeSet<Enrolment>(
            Collections.reverseOrder(CurriculumModule.COMPARATOR_BY_CREATION_DATE));
    orderedEnrolmentSet.addAll(getStudentCurricularPlan().getEnrolmentsByExecutionYear(getForExecutionYear()));

    return orderedEnrolmentSet.isEmpty() ? null
            : orderedEnrolmentSet.iterator().next().getCreationDateDateTime().toLocalDate();
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.teacher.FinalWorkManagementAction.java

@SuppressWarnings({ "deprecation", "unused" })
public ActionForward listProposals(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response)/*  w ww . ja v  a  2  s.c  om*/
        throws FenixActionException, FenixServiceException, IllegalAccessException, InstantiationException {
    final User userView = Authenticate.getUser();

    TreeSet<Proposal> proposals = new TreeSet<Proposal>(new Comparator<Proposal>() {

        @Override
        public int compare(Proposal o1, Proposal o2) {
            return o1.getProposalNumber().compareTo(o2.getProposalNumber());
        }
    });
    proposals.addAll(userView.getPerson().findFinalDegreeWorkProposals());
    request.setAttribute("proposals", proposals);

    String executionDegreeString = (String) getFromRequest(request, "degree");
    ExecutionDegree executionDegree = FenixFramework.getDomainObject(executionDegreeString);

    if (executionDegree == null) {
        ActionErrors actionErrors = new ActionErrors();
        actionErrors.add("finalDegreeWorkProposal.ProposalPeriod.interval.undefined",
                new ActionError("finalDegreeWorkProposal.ProposalPeriod.interval.undefined"));
        saveErrors(request, actionErrors);
        return mapping.findForward("OutOfSubmisionPeriod");
    } else {
        final DegreeCurricularPlan dcp = executionDegree.getDegreeCurricularPlan();
        final Set<ExecutionDegree> executionDegrees = dcp.getExecutionDegreesWithProposalPeriodOpen();
        if (executionDegrees.isEmpty()) {
            ActionErrors actionErrors = new ActionErrors();
            actionErrors.add("finalDegreeWorkProposal.ProposalPeriod.interval.undefined",
                    new ActionError("finalDegreeWorkProposal.ProposalPeriod.interval.undefined"));
            saveErrors(request, actionErrors);
            return mapping.findForward("OutOfSubmisionPeriod");
        }

        /*
         * This is done this way because executionDegrees set is a tree set
         * reversely order by ExecutionYear, so the first element in the set
         * is the most recent degree which has a submission proposal period
         * opened.
         */
        final ExecutionDegree recentDegree = executionDegrees.iterator().next();
        request.setAttribute("executionYear", recentDegree.getExecutionYear().getExternalId().toString());
        request.setAttribute("explicitYear", recentDegree.getExecutionYear().getName());

        request.setAttribute("degree", recentDegree.getExternalId().toString());
        request.setAttribute("explicitDegree", recentDegree.getDegree().getName());

        request.setAttribute("executionDegrees", executionDegrees);
        return mapping.findForward("listProposals");
    }
}

From source file:uk.ac.bbsrc.tgac.miso.spring.ajax.PoolControllerHelperService.java

public JSONObject selectDilutionsByBarcodeList(HttpSession session, JSONObject json) {
    try {//from w ww . ja  v a  2 s  . c om
        if (json.has("barcodes")) {
            String barcodes = json.getString("barcodes");
            String[] codes = barcodes.split("\n");

            // make sure there are no duplicates and order the strings
            // by putitng the codes in a treeset        
            TreeSet<String> hcodes = new TreeSet<String>();
            hcodes.addAll(Arrays.asList(codes));

            StringBuilder sb = new StringBuilder();
            sb.append("<form action='/miso/pool/import' method='post'>");
            sb.append("<div style='width: 100%;'>");
            sb.append(processDilutions(hcodes));
            sb.append("</form>");
            sb.append("</div>");
            session.removeAttribute("barcodes");

            return JSONUtils.SimpleJSONResponse(sb.toString());
        }
    } catch (Exception e) {
        log.debug("Failed to generate barcode selection: ", e);
        return JSONUtils.SimpleJSONError("Failed to generate barcode selection");
    }
    return JSONUtils.SimpleJSONError("Cannot select barcodes");
}

From source file:uk.ac.bbsrc.tgac.miso.spring.ajax.PoolControllerHelperService.java

@Deprecated
public JSONObject selectLibraryDilutionsByBarcodeList(HttpSession session, JSONObject json) {
    try {/*  w w  w.jav a  2  s  . co m*/
        if (json.has("barcodes")) {
            String barcodes = json.getString("barcodes");
            String[] codes = barcodes.split("\n");

            // make sure there are no duplicates and order the strings
            // by putitng the codes in a treeset
            TreeSet<String> hcodes = new TreeSet<String>();
            hcodes.addAll(Arrays.asList(codes));

            StringBuilder sb = new StringBuilder();
            sb.append("<form action='/miso/pool/illumina/import' method='post'>");
            sb.append("<div style='width: 100%;'>");
            sb.append(processLibraryDilutions(hcodes));
            sb.append("</form>");
            sb.append("</div>");
            session.removeAttribute("barcodes");

            return JSONUtils.SimpleJSONResponse(sb.toString());
        }
    } catch (Exception e) {
        log.debug("Failed to generate barcode selection: ", e);
        return JSONUtils.SimpleJSONError("Failed to generate barcode selection");
    }
    return JSONUtils.SimpleJSONError("Cannot select barcodes");
}

From source file:uk.ac.bbsrc.tgac.miso.spring.ajax.PoolControllerHelperService.java

public JSONObject selectDilutionsByBarcodeFile(HttpSession session, JSONObject json) {
    try {/*from ww w . java2s.  com*/
        JSONObject barcodes = (JSONObject) session.getAttribute("barcodes");
        log.debug(barcodes.toString());
        if (barcodes.has("barcodes")) {
            JSONArray a = barcodes.getJSONArray("barcodes");

            // make sure there are no duplicates and order the strings
            // by putitng the codes in a treeset
            TreeSet<String> hcodes = new TreeSet<String>();
            hcodes.addAll(Arrays.asList((String[]) a.toArray(new String[0])));

            StringBuilder sb = new StringBuilder();
            sb.append("<form action='/miso/pool/import' method='post'>");
            sb.append("<div style='width: 100%;'>");
            sb.append(processDilutions(hcodes));
            sb.append("</form>");
            sb.append("</div>");
            session.removeAttribute("barcodes");

            return JSONUtils.SimpleJSONResponse(sb.toString());
        }
    } catch (Exception e) {
        log.debug("Failed to generate barcode selection: ", e);
        return JSONUtils.SimpleJSONError("Failed to generate barcode selection");
    }
    return JSONUtils.SimpleJSONError("Cannot select barcodes");
}

From source file:uk.ac.bbsrc.tgac.miso.spring.ajax.PoolControllerHelperService.java

@Deprecated
public JSONObject selectLibraryDilutionsByBarcodeFile(HttpSession session, JSONObject json) {
    try {//w  ww. j  av a  2  s  . co m
        JSONObject barcodes = (JSONObject) session.getAttribute("barcodes");
        log.debug(barcodes.toString());
        if (barcodes.has("barcodes")) {
            JSONArray a = barcodes.getJSONArray("barcodes");

            // make sure there are no duplicates and order the strings
            // by putitng the codes in a treeset
            TreeSet<String> hcodes = new TreeSet<String>();
            hcodes.addAll(Arrays.asList((String[]) a.toArray(new String[0])));

            StringBuilder sb = new StringBuilder();
            sb.append("<form action='/miso/pool/import' method='post'>");
            sb.append("<div style='width: 100%;'>");
            sb.append(processLibraryDilutions(hcodes));
            sb.append("</form>");
            sb.append("</div>");
            session.removeAttribute("barcodes");

            return JSONUtils.SimpleJSONResponse(sb.toString());
        }
    } catch (Exception e) {
        log.debug("Failed to generate barcode selection: ", e);
        return JSONUtils.SimpleJSONError("Failed to generate barcode selection");
    }
    return JSONUtils.SimpleJSONError("Cannot select barcodes");
}

From source file:uk.ac.bbsrc.tgac.miso.spring.ajax.PoolControllerHelperService.java

@Deprecated
public JSONObject select454EmPCRDilutionsByBarcodeList(HttpSession session, JSONObject json) {
    try {//from  www  .j a  v  a 2  s  .c  o m
        if (json.has("barcodes")) {
            String barcodes = json.getString("barcodes");
            String[] codes = barcodes.split("\n");

            // make sure there are no duplicates and order the strings
            // by putitng the codes in a treeset
            TreeSet<String> hcodes = new TreeSet<String>();
            hcodes.addAll(Arrays.asList(codes));

            StringBuilder sb = new StringBuilder();
            sb.append("<div style='width: 100%;'>");
            sb.append("<form action='/miso/pool/ls454/import' method='post'>");
            sb.append(processEmPcrDilutions(hcodes));
            sb.append("</form>");
            sb.append("</div>");

            session.removeAttribute("barcodes");

            return JSONUtils.SimpleJSONResponse(sb.toString());
        }
    } catch (Exception e) {
        log.debug("Failed to generate barcode selection: ", e);
        return JSONUtils.SimpleJSONError("Failed to generate barcode selection");
    }
    return JSONUtils.SimpleJSONError("Cannot select barcodes");
}

From source file:uk.ac.bbsrc.tgac.miso.spring.ajax.PoolControllerHelperService.java

@Deprecated
public JSONObject selectSolidEmPCRDilutionsByBarcodeList(HttpSession session, JSONObject json) {
    try {//from  www . j  a  va2  s .co m
        if (json.has("barcodes")) {
            String barcodes = json.getString("barcodes");
            String[] codes = barcodes.split("\n");

            // make sure there are no duplicates and order the strings
            // by putitng the codes in a treeset
            TreeSet<String> hcodes = new TreeSet<String>();
            hcodes.addAll(Arrays.asList(codes));

            StringBuilder sb = new StringBuilder();
            sb.append("<div style='width: 100%;'>");
            sb.append("<form action='/miso/pool/solid/import' method='post'>");
            sb.append(processEmPcrDilutions(hcodes));
            sb.append("</form>");
            sb.append("</div>");

            session.removeAttribute("barcodes");

            return JSONUtils.SimpleJSONResponse(sb.toString());
        }
    } catch (Exception e) {
        log.debug("Failed to generate barcode selection: ", e);
        return JSONUtils.SimpleJSONError("Failed to generate barcode selection");
    }
    return JSONUtils.SimpleJSONError("Cannot select barcodes");
}