Example usage for java.util Set retainAll

List of usage examples for java.util Set retainAll

Introduction

In this page you can find the example usage for java.util Set retainAll.

Prototype

boolean retainAll(Collection<?> c);

Source Link

Document

Retains only the elements in this set that are contained in the specified collection (optional operation).

Usage

From source file:org.sakaiproject.assignment.impl.AssignmentServiceImpl.java

@Override
public List<User> allowGradeAssignmentUsers(String assignmentReference) {
    List<User> users = securityService.unlockUsers(SECURE_GRADE_ASSIGNMENT_SUBMISSION, assignmentReference);
    String assignmentId = AssignmentReferenceReckoner.reckoner().reference(assignmentReference).reckon()
            .getId();//from   w  ww  .  j a  v a 2  s  . co m
    try {
        Assignment a = getAssignment(assignmentId);
        if (a.getTypeOfAccess() == GROUP) {
            // for grouped assignment, need to include those users that with "all.groups" and "grade assignment" permissions on the site level
            try {
                AuthzGroup group = authzGroupService.getAuthzGroup(siteService.siteReference(a.getContext()));
                // get the roles which are allowed for submission but not for all_site control
                Set<String> rolesAllowAllSite = group.getRolesIsAllowed(SECURE_ALL_GROUPS);
                Set<String> rolesAllowGradeAssignment = group
                        .getRolesIsAllowed(SECURE_GRADE_ASSIGNMENT_SUBMISSION);
                // save all the roles with both "all.groups" and "grade assignment" permissions
                if (rolesAllowAllSite != null)
                    rolesAllowAllSite.retainAll(rolesAllowGradeAssignment);
                if (rolesAllowAllSite != null && rolesAllowAllSite.size() > 0) {
                    for (String aRolesAllowAllSite : rolesAllowAllSite) {
                        Set<String> userIds = group.getUsersHasRole(aRolesAllowAllSite);
                        if (userIds != null) {
                            for (String userId : userIds) {
                                try {
                                    User u = userDirectoryService.getUser(userId);
                                    if (!users.contains(u)) {
                                        users.add(u);
                                    }
                                } catch (Exception ee) {
                                    log.warn("problem with getting user = {}, {}", userId, ee.getMessage());
                                }
                            }
                        }
                    }
                }
            } catch (GroupNotDefinedException gnde) {
                log.warn("Cannot get authz group for site = {}, {}", a.getContext(), gnde.getMessage());
            }
        }
    } catch (Exception e) {
        log.warn("Could not fetch assignment with assignmentId = {}", assignmentId, e);
    }

    return users;
}

From source file:org.wso2.carbon.apimgt.impl.APIProviderImpl.java

/**
 * Updates an existing API//from  w  w w. j  ava  2  s .c o  m
 *
 * @param api API
 * @throws org.wso2.carbon.apimgt.api.APIManagementException
 *          if failed to update API
 * @throws org.wso2.carbon.apimgt.api.FaultGatewaysException on Gateway Failure
 */
@Override
public void updateAPI(API api) throws APIManagementException, FaultGatewaysException {

    boolean isValid = isAPIUpdateValid(api);
    if (!isValid) {
        throw new APIManagementException(" User doesn't have permission for update");
    }

    Map<String, Map<String, String>> failedGateways = new ConcurrentHashMap<String, Map<String, String>>();
    API oldApi = getAPI(api.getId());
    if (oldApi.getStatus().equals(api.getStatus())) {

        String previousDefaultVersion = getDefaultVersion(api.getId());
        String publishedDefaultVersion = getPublishedDefaultVersion(api.getId());

        if (previousDefaultVersion != null) {

            APIIdentifier defaultAPIId = new APIIdentifier(api.getId().getProviderName(),
                    api.getId().getApiName(), previousDefaultVersion);
            if (api.isDefaultVersion() ^ api.getId().getVersion().equals(previousDefaultVersion)) { // A change has
                                                                                                    // happen
                                                                                                    // Remove the previous default API entry from the Registry
                updateDefaultAPIInRegistry(defaultAPIId, false);
                if (!api.isDefaultVersion()) {// default api tick is removed
                    // todo: if it is ok, these two variables can be put to the top of the function to remove
                    // duplication
                    APIManagerConfiguration config = ServiceReferenceHolder.getInstance()
                            .getAPIManagerConfigurationService().getAPIManagerConfiguration();
                    String gatewayType = config.getFirstProperty(APIConstants.API_GATEWAY_TYPE);
                    if (APIConstants.API_GATEWAY_TYPE_SYNAPSE.equalsIgnoreCase(gatewayType)) {
                        removeDefaultAPIFromGateway(api);
                    }
                }
            }
        }

        //Update WSDL in the registry
        if (api.getWsdlUrl() != null) {
            updateWsdl(api);
        }

        boolean updatePermissions = false;
        if (!oldApi.getVisibility().equals(api.getVisibility())
                || (APIConstants.API_RESTRICTED_VISIBILITY.equals(oldApi.getVisibility())
                        && !api.getVisibleRoles().equals(oldApi.getVisibleRoles()))) {
            updatePermissions = true;
        }
        updateApiArtifact(api, true, updatePermissions);
        if (!oldApi.getContext().equals(api.getContext())) {
            api.setApiHeaderChanged(true);
        }

        int tenantId;
        String tenantDomain = MultitenantUtils
                .getTenantDomain(APIUtil.replaceEmailDomainBack(api.getId().getProviderName()));
        try {
            tenantId = ServiceReferenceHolder.getInstance().getRealmService().getTenantManager()
                    .getTenantId(tenantDomain);
        } catch (UserStoreException e) {
            throw new APIManagementException(
                    "Error in retrieving Tenant Information while updating api :" + api.getId().getApiName(),
                    e);
        }
        apiMgtDAO.updateAPI(api, tenantId);
        if (log.isDebugEnabled()) {
            log.debug("Successfully updated the API: " + api.getId() + " in the database");
        }

        JSONObject apiLogObject = new JSONObject();
        apiLogObject.put(APIConstants.AuditLogConstants.NAME, api.getId().getApiName());
        apiLogObject.put(APIConstants.AuditLogConstants.CONTEXT, api.getContext());
        apiLogObject.put(APIConstants.AuditLogConstants.VERSION, api.getId().getVersion());
        apiLogObject.put(APIConstants.AuditLogConstants.PROVIDER, api.getId().getProviderName());

        APIUtil.logAuditMessage(APIConstants.AuditLogConstants.API, apiLogObject.toString(),
                APIConstants.AuditLogConstants.UPDATED, this.username);

        APIManagerConfiguration config = ServiceReferenceHolder.getInstance()
                .getAPIManagerConfigurationService().getAPIManagerConfiguration();
        boolean gatewayExists = config.getApiGatewayEnvironments().size() > 0;
        String gatewayType = config.getFirstProperty(APIConstants.API_GATEWAY_TYPE);
        boolean isAPIPublished = false;
        // gatewayType check is required when API Management is deployed on other servers to avoid synapse
        if (APIConstants.API_GATEWAY_TYPE_SYNAPSE.equalsIgnoreCase(gatewayType)) {
            isAPIPublished = isAPIPublished(api);
            if (gatewayExists) {
                if (isAPIPublished) {
                    API apiPublished = getAPI(api.getId());
                    apiPublished.setAsDefaultVersion(api.isDefaultVersion());
                    if (api.getId().getVersion().equals(previousDefaultVersion) && !api.isDefaultVersion()) {
                        // default version tick has been removed so a default api for current should not be
                        // added/updated
                        apiPublished.setAsPublishedDefaultVersion(false);
                    } else {
                        apiPublished.setAsPublishedDefaultVersion(
                                api.getId().getVersion().equals(publishedDefaultVersion));
                    }
                    apiPublished.setOldInSequence(oldApi.getInSequence());
                    apiPublished.setOldOutSequence(oldApi.getOutSequence());
                    //old api contain what environments want to remove
                    Set<String> environmentsToRemove = new HashSet<String>(oldApi.getEnvironments());
                    //updated api contain what environments want to add
                    Set<String> environmentsToPublish = new HashSet<String>(apiPublished.getEnvironments());
                    Set<String> environmentsRemoved = new HashSet<String>(oldApi.getEnvironments());
                    if (!environmentsToPublish.isEmpty() && !environmentsToRemove.isEmpty()) {
                        // this block will sort what gateways have to remove and published
                        environmentsRemoved.retainAll(environmentsToPublish);
                        environmentsToRemove.removeAll(environmentsRemoved);
                    }
                    // map contain failed to publish Environments
                    Map<String, String> failedToPublishEnvironments = publishToGateway(apiPublished);
                    apiPublished.setEnvironments(environmentsToRemove);
                    // map contain failed to remove Environments
                    Map<String, String> failedToRemoveEnvironments = removeFromGateway(apiPublished);
                    environmentsToPublish.removeAll(failedToPublishEnvironments.keySet());
                    environmentsToPublish.addAll(failedToRemoveEnvironments.keySet());
                    apiPublished.setEnvironments(environmentsToPublish);
                    updateApiArtifact(apiPublished, true, false);
                    failedGateways.clear();
                    failedGateways.put("UNPUBLISHED", failedToRemoveEnvironments);
                    failedGateways.put("PUBLISHED", failedToPublishEnvironments);
                } else if (api.getStatus() != APIStatus.CREATED && api.getStatus() != APIStatus.RETIRED) {
                    if ("INLINE".equals(api.getImplementation()) && api.getEnvironments().isEmpty()) {
                        api.setEnvironments(
                                ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService()
                                        .getAPIManagerConfiguration().getApiGatewayEnvironments().keySet());
                    }
                    Map<String, String> failedToPublishEnvironments = publishToGateway(api);
                    if (!failedToPublishEnvironments.isEmpty()) {
                        Set<String> publishedEnvironments = new HashSet<String>(api.getEnvironments());
                        publishedEnvironments.removeAll(failedToPublishEnvironments.keySet());
                        api.setEnvironments(publishedEnvironments);
                        updateApiArtifact(api, true, false);
                        failedGateways.clear();
                        failedGateways.put("PUBLISHED", failedToPublishEnvironments);
                        failedGateways.put("UNPUBLISHED", Collections.<String, String>emptyMap());
                    }
                }
            } else {
                log.debug("Gateway is not existed for the current API Provider");
            }
        }

        //If gateway(s) exist, remove resource paths saved on the cache.

        if (gatewayExists && isAPIPublished && !oldApi.getUriTemplates().equals(api.getUriTemplates())) {
            Set<URITemplate> resourceVerbs = api.getUriTemplates();

            Map<String, Environment> gatewayEns = config.getApiGatewayEnvironments();
            for (Environment environment : gatewayEns.values()) {
                try {
                    APIAuthenticationAdminClient client = new APIAuthenticationAdminClient(environment);
                    if (resourceVerbs != null) {
                        for (URITemplate resourceVerb : resourceVerbs) {
                            String resourceURLContext = resourceVerb.getUriTemplate();
                            client.invalidateResourceCache(api.getContext(), api.getId().getVersion(),
                                    resourceURLContext, resourceVerb.getHTTPVerb());
                            if (log.isDebugEnabled()) {
                                log.debug("Calling invalidation cache");
                            }
                        }
                    }
                } catch (AxisFault ex) {
                    /*
                    didn't throw this exception to handle multiple gateway publishing feature therefore
                    this didn't break invalidating cache from the all the gateways if one gateway is
                    unreachable
                    */
                    log.error("Error while invalidating from environment " + environment.getName(), ex);
                }
            }

        }

        // update apiContext cache
        if (APIUtil.isAPIManagementEnabled()) {
            Cache contextCache = APIUtil.getAPIContextCache();
            contextCache.remove(oldApi.getContext());
            contextCache.put(api.getContext(), Boolean.TRUE);
        }

    } else {
        // We don't allow API status updates via this method.
        // Use changeAPIStatus for that kind of updates.
        throw new APIManagementException("Invalid API update operation involving API status changes");
    }
    if (!failedGateways.isEmpty()
            && (!failedGateways.get("UNPUBLISHED").isEmpty() || !failedGateways.get("PUBLISHED").isEmpty())) {
        throw new FaultGatewaysException(failedGateways);
    }
}

From source file:edu.cmu.tetrad.search.TestIndTestConditionalCorrelation.java

public void test14c7() {
    try {//from w  w  w.  j  a v  a 2 s .c o  m
        String graphDir = "/Users/josephramsey/Documents/LAB_NOTEBOOK.2012.04.20/2013.11.23/test14/";
        File _graphDir = new File(graphDir);

        if (!_graphDir.exists())
            _graphDir.mkdir();

        double penalty = 1.0;
        double clip = 0.9;

        List<Graph> partitionGraph = new ArrayList<Graph>();

        List<DataSet> dataSets = loadDataSets();

        Lofs2.Rule rule = null; //Lofs2.Rule.R3;
        //            Lofs2.Rule rule = Lofs2.Rule.R3;

        for (int partition = 1; partition <= 6; partition++) {
            File dir1 = _graphDir; //new File(graphDir, "images.partition");

            String tag = "images";

            //                String filename1 = "graph.partition." + "images" + "." + penalty + "." + partition + ".txt";
            String filename1 = "graph.partition." + tag + "." + penalty + "." + partition + ".clip" + clip
                    + ".txt";

            File file1 = new File(dir1, filename1);

            Graph graph = GraphUtils.loadGraphTxt(file1);

            if (rule != null) {
                Lofs2 lofs = new Lofs2(graph, partitionDataSets(dataSets, partition, 67, 10));
                lofs.setRule(rule);
                lofs.setAlpha(1.0);
                graph = lofs.orient();
            }

            partitionGraph.add(graph);

        }

        Graph firstGraph = partitionGraph.get(0);
        List<Node> nodes = firstGraph.getNodes();
        Graph firstGraphUndirected = GraphUtils.undirectedGraph(firstGraph);
        Set<Edge> undirectedEdges = new HashSet<Edge>(firstGraphUndirected.getEdges());

        for (int i = 1; i < partitionGraph.size(); i++) {
            Graph _graph = partitionGraph.get(i);
            Graph _graphUndirected = GraphUtils.replaceNodes(_graph, nodes);
            _graphUndirected = GraphUtils.undirectedGraph(_graphUndirected);

            undirectedEdges.retainAll(_graphUndirected.getEdges());
        }

        Graph intersectionUndirected = new EdgeListGraph(firstGraphUndirected.getNodes());

        for (Edge edge : undirectedEdges) {
            intersectionUndirected.addEdge(edge);
        }

        List<Graph> undirectedPartitionGraphs = new ArrayList<Graph>();

        for (Graph graph : partitionGraph) {
            graph = GraphUtils.replaceNodes(graph, nodes);
            graph = GraphUtils.undirectedGraph(graph);
            undirectedPartitionGraphs.add(graph);
        }

        Set<Edge> allEdges = new HashSet<Edge>();

        for (Graph graph : undirectedPartitionGraphs) {
            allEdges.addAll(graph.getEdges());
        }

        int index = 0;
        List<Edge> target = new ArrayList<Edge>();
        int minCount1 = 4;
        int minCount2 = minCount1;

        for (Edge edge : allEdges) {//intersectionUndirected.getEdges()) {
            //                if (intersectionUndirected.containsEdge(edge)) continue;

            int count = 0;

            for (Graph graph : undirectedPartitionGraphs) {
                graph = GraphUtils.replaceNodes(graph, nodes);
                if (graph.containsEdge(edge))
                    count++;
            }

            System.out.println((++index) + ". " + edge + " " + count);

            if (count >= minCount1) {
                target.add(edge);
            }
        }

        Graph targetGraph = new EdgeListGraph(nodes);

        for (Edge edge : target) {
            targetGraph.addEdge(edge);
        }

        //            writeFiveGraphFormats(graphDir, targetGraph, "intersection.5or6consistent." + penalty + ".txt");

        Graph intersectionConsistent = new EdgeListGraph(nodes);

        for (Edge edge : targetGraph.getEdges()) {
            Edge edge1 = Edges.directedEdge(edge.getNode1(), edge.getNode2());
            Edge edge2 = Edges.directedEdge(edge.getNode2(), edge.getNode1());
            Edge edge3 = Edges.undirectedEdge(edge.getNode1(), edge.getNode2());

            int count1 = 0;
            int count2 = 0;

            for (Graph graph : partitionGraph) {
                if (graph.containsEdge(edge1))
                    count1++;
                if (graph.containsEdge(edge2))
                    count2++;
            }

            if (count1 >= minCount2) {
                intersectionConsistent.addEdge(edge1);
            } else if (count2 >= minCount2) {
                intersectionConsistent.addEdge(edge2);
            } else {
                intersectionConsistent.addEdge(edge3);
            }
        }

        //            writeGraph(new File(graphDir, "intersectionConsistent." +
        //                    minCount1 + "." + minCount2 + "." + penalty + ".txt"), intersectionConsistent);
        writeFiveGraphFormats(graphDir, intersectionConsistent, "intersectionConsistent." + minCount1 + "."
                + minCount2 + "." + penalty + ".clip" + clip + ".txt");

        Map<String, Coord> map = loadMap();

        List<Edge> edges = intersectionConsistent.getEdges();
        Collections.sort(edges);

        for (Edge edge : edges) {
            Node node1 = edge.getNode1();
            Node node2 = edge.getNode2();

            String name1 = node1.getName();
            String name2 = node2.getName();

            Coord coord1 = map.get(name1);
            Coord coord2 = map.get(name2);

            boolean hub1 = intersectionConsistent.getAdjacentNodes(node1).size() >= 5;
            boolean hub2 = intersectionConsistent.getAdjacentNodes(node2).size() >= 5;

            Edge _edge = new Edge(new GraphNode(name1 + (hub1 ? "*" : "")),
                    new GraphNode(name2 + (hub2 ? "*" : "")), edge.getEndpoint1(), edge.getEndpoint2());

            double dx = coord1.getX() - coord2.getX();
            double dy = coord1.getY() - coord2.getY();
            double dz = coord1.getZ() - coord2.getZ();

            double d = sqrt(dx * dx + dy * dy + dz * dz);
            NumberFormat nf = new DecimalFormat("0.0");

            String side1 = coord1.getX() < 0 ? " (L)" : " (R)";
            String side2 = coord2.getX() < 0 ? " (L)" : " (R)";

            if (d > 50 && (hub1 || hub2)) {
                System.out.println(_edge + " " + nf.format(d) + " " + coord1.getArea() + side1 + "---"
                        + coord2.getArea() + side2);
            }
        }

        //            Graph graph = GraphUtils.loadGraphTxt(new File(graphDir, "2014.01.15b/intersection56Consistent.1.0.txt"));

        //            Graph dag = SearchGraphUtils.dagFromPattern(intersectionConsistent);
        //
        //            SemPm semPm = new SemPm(dag);
        //            GeneralizedSemPm pm = new GeneralizedSemPm(semPm);
        //            int numDataSets = dataSets.size();
        //
        //            List<SemEstimator> estimators = new ArrayList<SemEstimator>();
        //
        //            List<double[]> coefs = new ArrayList<double[]>();
        //
        //            List<String> parameters = new ArrayList<String>(pm.getParameters());
        //            Collections.sort(parameters);
        //
        //            for (int i = 0; i < parameters.size(); i++) {
        //                coefs.add(new double[numDataSets]);
        //            }

        //            int count = 0;
        //
        //            for (int i = 0; i < numDataSets; i++) {
        //                DataSet dataSet = dataSets.get(i);
        //                System.out.println(++count);
        //
        //                SemEstimator estimator = new SemEstimator(dataSet, semPm);
        //                estimator.setSemOptimizer(new SemOptimizerRegression());
        //                SemIm im = estimator.estimate();
        //                GeneralizedSemIm _im = new GeneralizedSemIm(pm, im);
        //
        //                estimators.add(estimator);
        //
        //                for (int k = 0; k < parameters.size(); k++) {
        //                    coefs.get(k)[i] = _im.getParameterValue(parameters.get(k));
        //                }
        //            }

        //            NumberFormat nf = new DecimalFormat("0.0000");
        //
        //            for (int i = 0; i < parameters.size(); i++) {
        //                String param = parameters.get(i);
        //
        //                if (!param.startsWith("B")) continue;
        //
        //                for (Parameter parameter1 : semPm.getParameters()) {
        //                    if (parameter1.getName().equals(param)) {
        //                        System.out.print(parameter1.getNodeA() + "-->" + parameter1.getNodeB() + ": ");
        //                        break;
        //                    }
        //                }
        //
        //                double[] _coefs = coefs.get(i);
        //                System.out.println("Coef = " + param + " mean = " + nf.format(StatUtils.mean(_coefs))
        //                        + " SE = " + nf.format(StatUtils.sd(_coefs)));
        //
        //            }

        //            System.out.println(pm);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.wso2.carbon.apimgt.impl.utils.APIUtil.java

public static Set<APIStore> getExternalAPIStores(Set<APIStore> inputStores, int tenantId)
        throws APIManagementException {
    SortedSet<APIStore> apiStores = new TreeSet<APIStore>(new APIStoreNameComparator());
    apiStores.addAll(getExternalStores(tenantId));
    //Retains only the stores that contained in configuration
    inputStores.retainAll(apiStores);
    boolean exists = false;
    if (!apiStores.isEmpty()) {
        for (APIStore store : apiStores) {
            for (APIStore inputStore : inputStores) {
                if (inputStore.getName().equals(store.getName())) { // If the configured apistore already stored in
                                                                    // db,ignore adding it again
                    exists = true;/*  w  w w  .  ja v a  2s . com*/
                }
            }
            if (!exists) {
                inputStores.add(store);
            }
            exists = false;
        }
    }
    return inputStores;
}

From source file:gov.nih.nci.ispy.service.clinical.ClinicalFileBasedQueryService.java

/**
 * This method gets the patient DIDs corresponding to the constraints in the 
 * clinical data query dto .  Note in the future may want to add capability to 
 * and and or constraints.  Currently the the constraints are OR ed.
 *//*from  w  w  w .  jav  a2  s . c om*/
public Set<String> getPatientDIDs(ISPYclinicalDataQueryDTO cDTO) {

    Set<TimepointType> timepoints = cDTO.getTimepointValues();
    Set<String> patientDIDs = null;
    Set<String> queryResult = null;

    Set<String> restrainingSamples = cDTO.getRestrainingSamples();

    //Get IDs for Clinical Stage
    if ((cDTO.getClinicalStageValues() != null) && (!cDTO.getClinicalStageValues().isEmpty())) {
        queryResult = getPatientDIDsForClinicalStage(cDTO.getClinicalStageValues());

        patientDIDs = addToPatientDIDs(patientDIDs, queryResult);
    }

    //Get IDs for ER status
    if ((cDTO.getErStatusValues() != null) && (!cDTO.getErStatusValues().isEmpty())) {

        queryResult = getPatientDIDsForERstatus(cDTO.getErStatusValues());

        patientDIDs = addToPatientDIDs(patientDIDs, queryResult);
    }

    //Get IDs for HER2 status
    if ((cDTO.getHer2StatusValues() != null) && (!cDTO.getHer2StatusValues().isEmpty())) {

        queryResult = getPatientDIDsForHER2status(cDTO.getHer2StatusValues());

        patientDIDs = addToPatientDIDs(patientDIDs, queryResult);
    }

    //Get IDs for PR status
    if ((cDTO.getPrStatusValues() != null) && (!cDTO.getPrStatusValues().isEmpty())) {

        queryResult = getPatientDIDsForPRstatus(cDTO.getPrStatusValues());

        patientDIDs = addToPatientDIDs(patientDIDs, queryResult);

    }

    //Get IDs for Clinical Response
    for (TimepointType tp : timepoints) {
        if ((cDTO.getClinicalResponseValues() != null) && (!cDTO.getClinicalResponseValues().isEmpty())) {
            //patientDIDs.addAll(getPatientDIDsForClinicalResponse(tp,cDTO.getClinicalResponseValues()));

            queryResult = getPatientDIDsForClinicalResponse(tp, cDTO.getClinicalResponseValues());

            patientDIDs = addToPatientDIDs(patientDIDs, queryResult);
        }
    }

    //Get IDs for NeoAdjuvantChemoRegimen
    if ((cDTO.getAgentValues() != null) && (!cDTO.getAgentValues().isEmpty())) {
        //patientDIDs.addAll(getPatientDIDsForNeoAdjuvantChemoRegimen(cDTO.getAgentValues()));
        queryResult = getPatientDIDsForNeoAdjuvantChemoRegimen(cDTO.getAgentValues());

        patientDIDs = addToPatientDIDs(patientDIDs, queryResult);
    }

    //Get IDs for % LD change
    if (cDTO.getPercentLDChangeType() != null) {

        // USE THESE to get the % ld values.
        //cDTO.getLdPercentChange();
        //cDTO.getLdPercentChangeOperator();
        Double ldPctChange = cDTO.getLdPercentChange();
        Operator operator = cDTO.getLdPercentChangeOperator();
        PercentLDChangeType changeType = cDTO.getPercentLDChangeType();

        queryResult = getPatientDIDsForPctLDchange(ldPctChange, changeType, operator);

        patientDIDs = addToPatientDIDs(patientDIDs, queryResult);

    }

    if (cDTO.getPathTumorSize() != null) {
        Double size = cDTO.getPathTumorSize();
        Operator operator = cDTO.getPathTumorSizeOperator();

        queryResult = getPatientsDIDsForPrimaryPathoMicroscopicTumorSize(size, operator);

        patientDIDs = addToPatientDIDs(patientDIDs, queryResult);

    }

    // get ids for residual cancer burden index

    if (cDTO.getRcbSize() != null) {
        Double size = cDTO.getRcbSize();
        Operator operator = cDTO.getRcbOperator();

        queryResult = getPatientsDIDsForRCBIndexSize(size, operator);

        patientDIDs = addToPatientDIDs(patientDIDs, queryResult);

    }

    // get patient ids for patholology complete response

    if ((cDTO.getPcrValues() != null) && (!cDTO.getPcrValues().isEmpty())) {

        queryResult = getPatientDIDsForPcr(cDTO.getPcrValues());

        patientDIDs = addToPatientDIDs(patientDIDs, queryResult);
    }

    //Get IDs for AgeCategory
    if (cDTO.getAgeCategoryValues() != null) {
        queryResult = getPatientDIDsForAgeCategory(cDTO.getAgeCategoryValues());

        patientDIDs = addToPatientDIDs(patientDIDs, queryResult);
    }

    //Get IDs for Race      
    if (cDTO.getRaceValues() != null) {
        queryResult = getPatientDIDsForRace(cDTO.getRaceValues());

        patientDIDs = addToPatientDIDs(patientDIDs, queryResult);
    }

    //Get the ids for morphology
    if ((cDTO.getMorphologyValues() != null) && (!cDTO.getMorphologyValues().isEmpty())) {

        queryResult = getPatientDIDsForMorphology(cDTO.getMorphologyValues());

        patientDIDs = addToPatientDIDs(patientDIDs, queryResult);
    }

    if ((restrainingSamples != null) && (!restrainingSamples.isEmpty())) {
        if (patientDIDs != null) {
            patientDIDs.retainAll(restrainingSamples);
        } else
            patientDIDs = restrainingSamples;
    }

    if (patientDIDs != null) {
        return patientDIDs;
    }

    return Collections.emptySet();

}

From source file:com.liferay.portal.tools.service.builder.ServiceBuilder.java

private List<String> _getTransients(Entity entity, boolean parent) throws Exception {

    File modelFile = null;//from ww  w.j  av  a  2 s.  co  m

    if (parent) {
        modelFile = new File(_outputPath + "/model/impl/" + entity.getName() + "ModelImpl.java");
    } else {
        modelFile = new File(_outputPath + "/model/impl/" + entity.getName() + "Impl.java");
    }

    String content = FileUtils.readFileToString(modelFile);

    Matcher matcher = _getterPattern.matcher(content);

    Set<String> getters = new HashSet<>();

    while (!matcher.hitEnd()) {
        boolean found = matcher.find();

        if (found) {
            String property = matcher.group();

            if (property.contains("get")) {
                property = property.substring(property.indexOf("get") + 3, property.length() - 1);
            } else {
                property = property.substring(property.indexOf("is") + 2, property.length() - 1);
            }

            if (!entity.hasColumn(property) && !entity.hasColumn(Introspector.decapitalize(property))) {

                property = Introspector.decapitalize(property);

                getters.add(property);
            }
        }
    }

    matcher = _setterPattern.matcher(content);

    Set<String> setters = new HashSet<>();

    while (!matcher.hitEnd()) {
        boolean found = matcher.find();

        if (found) {
            String property = matcher.group();

            property = property.substring(property.indexOf("set") + 3, property.length() - 1);

            if (!entity.hasColumn(property) && !entity.hasColumn(Introspector.decapitalize(property))) {

                property = Introspector.decapitalize(property);

                setters.add(property);
            }
        }
    }

    getters.retainAll(setters);

    List<String> transients = new ArrayList<>(getters);

    Collections.sort(transients);

    return transients;
}

From source file:org.archiviststoolkit.mydomain.DomainAccessObjectImpl.java

private Collection findByQueryEditorAlt(QueryEditor editor, InfiniteProgressPanel progressPanel) {
    Session session;/*from w  w  w .j a v a2s.co  m*/
    Criteria criteria;
    Set returnCollection = new HashSet();
    Set subsequentCollections = null;
    Set returnComponentCollection = new HashSet();
    Set subsequentComponentCollections = null;
    HashMap<ResourcesComponents, Resources> componentParentResourceMap = new HashMap<ResourcesComponents, Resources>();
    HashMap<DomainObject, String> contextMap = new HashMap<DomainObject, String>();
    boolean includeComponents = false;
    ArrayList<ResourcesComponentsSearchResult> resourcesAndComponetsResults = new ArrayList<ResourcesComponentsSearchResult>();
    ResourcesComponents component;

    //this is a loop of set intersections. In the first pass create a set
    //in all subsequent passes create a new set and perform an intersection on the
    //two sets. Java does this with the set.retainAll() method.
    if (persistentClass == Accessions.class || persistentClass == Resources.class
            || persistentClass == DigitalObjects.class) {
        //if we are including components then initialize the return set
        if (persistentClass == Resources.class && editor.getIncludeComponentsRelatedSearch()) {
            includeComponents = true;
        }
        boolean firstPass = true;
        subsequentCollections = new HashSet();
        humanReadableSearchString = "";
        for (QueryEditor.CriteriaRelationshipPairs criteriaPair : editor.getAltFormCriteria()) {
            session = SessionFactory.getInstance().openSession(null, getPersistentClass(), true);
            criteria = processCriteria(session, editor.getClazz(), criteriaPair);

            // if searching digital objects then need to see if to only search for parent digital objects
            if (persistentClass == DigitalObjects.class && !editor.getIncludeComponents()) {
                criteria.add(Restrictions.isNull("parent"));
            }

            if (firstPass) {
                returnCollection = new HashSet(criteria.list());
            } else {
                subsequentCollections = new HashSet(criteria.list());
            }
            if (includeComponents) {
                addContextInfo(contextMap, criteria.list(), criteriaPair.getContext());
            }
            SessionFactory.getInstance().closeSession(session);

            if (persistentClass == Resources.class && !criteriaPair.getResourceOnly() && includeComponents) {
                subsequentComponentCollections = new HashSet();
                session = SessionFactory.getInstance().openSession(ResourcesComponents.class);
                criteria = processCriteria(session, ResourcesComponents.class, criteriaPair, false);
                ResourcesDAO resourceDao = new ResourcesDAO();
                Resources resource;
                progressPanel.setTextLine("Searching for components that match the criteria", 2);
                Collection components = criteria.list();
                int numberOfComponents = components.size();
                int count = 1;
                for (Object object : components) {
                    progressPanel.setTextLine(
                            "Gathering resources by component matches " + count++ + " of " + numberOfComponents,
                            2);
                    component = (ResourcesComponents) object;
                    resource = resourceDao.findResourceByComponent(component);
                    componentParentResourceMap.put(component, resource);
                    addContextInfo(contextMap, component, criteriaPair.getContext());
                    if (firstPass) {
                        //if you are including components then add the component to the result set
                        //otherwise add the parent resource
                        if (includeComponents) {
                            returnComponentCollection.add(component);
                        } else {
                            returnCollection.add(resource);
                        }
                    } else {
                        //if you are including components then add the component to the result set
                        //otherwise add the parent resource
                        if (includeComponents) {
                            subsequentComponentCollections.add(object);
                        } else {
                            subsequentCollections.add(resource);
                        }
                    }
                }
                SessionFactory.getInstance().closeSession(session);
            }
            if (firstPass) {
                firstPass = false;
            } else {
                returnCollection.retainAll(subsequentCollections);
                if (includeComponents) {
                    returnComponentCollection.retainAll(subsequentComponentCollections);
                }
            }
        }
    }
    progressPanel.close();
    if (includeComponents) {
        addResourcesCommonToComponetResultSet(returnCollection, resourcesAndComponetsResults, contextMap);
        addResourcesCommonToComponetResultSet(returnComponentCollection, resourcesAndComponetsResults,
                contextMap, componentParentResourceMap);
        return resourcesAndComponetsResults;
    } else {
        return returnCollection;
    }
}

From source file:org.alfresco.repo.security.authority.AuthorityDAOBridgeTableImpl.java

public Set<String> findAuthorities(AuthorityType type, String parentAuthority, boolean immediate,
        String displayNamePattern, String zoneName) {
    Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);

    Pattern pattern = displayNamePattern == null ? null
            : Pattern.compile(SearchLanguageConversion.convert(SearchLanguageConversion.DEF_LUCENE,
                    SearchLanguageConversion.DEF_REGEX, displayNamePattern), Pattern.CASE_INSENSITIVE);

    // Use SQL to determine root authorities
    Set<String> rootAuthorities = null;
    if (parentAuthority == null && immediate) {
        rootAuthorities = getRootAuthorities(type, zoneName);
        if (pattern == null) {
            if (start != null) {
                logger.debug("findAuthorities (rootAuthories): " + rootAuthorities.size() + " items in "
                        + (System.currentTimeMillis() - start) + " msecs [type=" + type + ",zone=" + zoneName
                        + "]");
            }//from   w ww .  ja va 2s  . c o  m

            return rootAuthorities;
        }
    }

    // Use a Lucene search for other criteria
    Set<String> authorities = new TreeSet<String>();
    SearchParameters sp = new SearchParameters();
    sp.addStore(this.storeRef);
    sp.setLanguage("lucene");
    StringBuilder query = new StringBuilder(500);
    if (type == null || type == AuthorityType.USER) {
        if (type == null) {
            query.append("((");
        }
        query.append("TYPE:\"").append(ContentModel.TYPE_PERSON).append("\"");
        if (displayNamePattern != null) {
            query.append(" AND @")
                    .append(AbstractLuceneQueryParser.escape("{" + ContentModel.PROP_USERNAME.getNamespaceURI()
                            + "}" + ISO9075.encode(ContentModel.PROP_USERNAME.getLocalName())))
                    .append(":\"").append(AbstractLuceneQueryParser.escape(displayNamePattern)).append("\"");

        }
        if (type == null) {
            query.append(") OR (");
        }
    }
    if (type != AuthorityType.USER) {
        query.append("TYPE:\"").append(ContentModel.TYPE_AUTHORITY_CONTAINER).append("\"");
        if (displayNamePattern != null) {
            query.append(" AND (");
            if (!displayNamePattern.startsWith("*")) {
                // Allow for the appropriate type prefix in the authority
                // name
                Collection<AuthorityType> authorityTypes = type == null ? SEARCHABLE_AUTHORITY_TYPES
                        : Collections.singleton(type);
                boolean first = true;
                for (AuthorityType subType : authorityTypes) {
                    if (first) {
                        first = false;
                    } else {
                        query.append(" OR ");
                    }
                    query.append("@")
                            .append(AbstractLuceneQueryParser
                                    .escape("{" + ContentModel.PROP_AUTHORITY_NAME.getNamespaceURI() + "}"
                                            + ISO9075.encode(ContentModel.PROP_AUTHORITY_NAME.getLocalName())))
                            .append(":\"");
                    query.append(getName(subType, AbstractLuceneQueryParser.escape(displayNamePattern)))
                            .append("\"");

                }
            } else {
                query.append("@")
                        .append(AbstractLuceneQueryParser
                                .escape("{" + ContentModel.PROP_AUTHORITY_NAME.getNamespaceURI() + "}"
                                        + ISO9075.encode(ContentModel.PROP_AUTHORITY_NAME.getLocalName())))
                        .append(":\"");
                query.append(getName(type, AbstractLuceneQueryParser.escape(displayNamePattern))).append("\"");
            }
            query.append(" OR @")
                    .append(AbstractLuceneQueryParser
                            .escape("{" + ContentModel.PROP_AUTHORITY_DISPLAY_NAME.getNamespaceURI() + "}"
                                    + ISO9075.encode(ContentModel.PROP_AUTHORITY_DISPLAY_NAME.getLocalName())))
                    .append(":\"").append(AbstractLuceneQueryParser.escape(displayNamePattern)).append("\")");
        }
        if (type == null) {
            query.append("))");
        }
    }
    if (parentAuthority != null) {
        if (immediate) {
            // use PARENT
            NodeRef parentAuthorityNodeRef = getAuthorityNodeRefOrNull(parentAuthority);
            if (parentAuthorityNodeRef != null) {
                query.append(" AND PARENT:\"")
                        .append(AbstractLuceneQueryParser.escape(parentAuthorityNodeRef.toString()))
                        .append("\"");
            } else {
                throw new UnknownAuthorityException("An authority was not found for " + parentAuthority);
            }
        } else {
            // use PATH
            query.append(" AND PATH:\"/sys:system/sys:authorities/cm:").append(ISO9075.encode(parentAuthority));
            query.append("//*\"");
        }
    }
    if (zoneName != null) {
        // Zones are all direct links to those within so it is safe to use
        // PARENT to look them up
        NodeRef zoneNodeRef = getZone(zoneName);
        if (zoneNodeRef != null) {
            query.append(" AND PARENT:\"").append(AbstractLuceneQueryParser.escape(zoneNodeRef.toString()))
                    .append("\"");
        } else {
            throw new UnknownAuthorityException("A zone was not found for " + zoneName);
        }
    }
    sp.setQuery(query.toString());
    sp.setMaxItems(100);
    ResultSet rs = null;
    try {
        rs = searchService.query(sp);

        for (ResultSetRow row : rs) {
            NodeRef nodeRef = row.getNodeRef();
            QName idProp = dictionaryService.isSubClass(nodeService.getType(nodeRef),
                    ContentModel.TYPE_AUTHORITY_CONTAINER) ? ContentModel.PROP_AUTHORITY_NAME
                            : ContentModel.PROP_USERNAME;
            addAuthorityNameIfMatches(authorities, DefaultTypeConverter.INSTANCE.convert(String.class,
                    nodeService.getProperty(nodeRef, idProp)), type, pattern);
        }

        // If we asked for root authorities, we must do an intersection with
        // the set of root authorities
        if (rootAuthorities != null) {
            authorities.retainAll(rootAuthorities);
        }

        if (start != null) {
            logger.debug("findAuthorities: " + authorities.size() + " items in "
                    + (System.currentTimeMillis() - start) + " msecs [type=" + type + ",zone=" + zoneName
                    + ",parent=" + parentAuthority + ",immediate=" + immediate + ",filter=" + displayNamePattern
                    + "]");
        }

        return authorities;
    } finally {
        if (rs != null) {
            rs.close();
        }
    }
}

From source file:org.alfresco.repo.security.authority.AuthorityDAOImpl.java

public Set<String> findAuthorities(AuthorityType type, String parentAuthority, boolean immediate,
        String displayNamePattern, String zoneName) {
    Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);

    Pattern pattern = displayNamePattern == null ? null
            : Pattern.compile(SearchLanguageConversion.convert(SearchLanguageConversion.DEF_LUCENE,
                    SearchLanguageConversion.DEF_REGEX, displayNamePattern), Pattern.CASE_INSENSITIVE);

    // Use SQL to determine root authorities
    Set<String> rootAuthorities = null;
    if (parentAuthority == null && immediate) {
        rootAuthorities = getRootAuthorities(type, zoneName);
        if (pattern == null) {
            if (start != null) {
                logger.debug("findAuthorities (rootAuthories): " + rootAuthorities.size() + " items in "
                        + (System.currentTimeMillis() - start) + " msecs [type=" + type + ",zone=" + zoneName
                        + "]");
            }/*from  www .j a v a 2  s  .  c om*/

            return rootAuthorities;
        }
    }

    // Use a Lucene search for other criteria
    Set<String> authorities = new TreeSet<String>();
    SearchParameters sp = new SearchParameters();
    sp.addStore(this.storeRef);
    sp.setLanguage("lucene");
    StringBuilder query = new StringBuilder(500);
    if (type == null || type == AuthorityType.USER) {
        if (type == null) {
            query.append("((");
        }
        query.append("TYPE:\"").append(ContentModel.TYPE_PERSON).append("\"");
        if (displayNamePattern != null) {
            query.append(" AND @")
                    .append(SearchLanguageConversion
                            .escapeLuceneQuery("{" + ContentModel.PROP_USERNAME.getNamespaceURI() + "}"
                                    + ISO9075.encode(ContentModel.PROP_USERNAME.getLocalName())))
                    .append(":\"").append(SearchLanguageConversion.escapeLuceneQuery(displayNamePattern))
                    .append("\"");

        }
        if (type == null) {
            query.append(") OR (");
        }
    }
    if (type != AuthorityType.USER) {
        query.append("TYPE:\"").append(ContentModel.TYPE_AUTHORITY_CONTAINER).append("\"");
        if (displayNamePattern != null) {
            query.append(" AND (");
            if (!displayNamePattern.startsWith("*")) {
                // Allow for the appropriate type prefix in the authority name
                Collection<AuthorityType> authorityTypes = type == null ? SEARCHABLE_AUTHORITY_TYPES
                        : Collections.singleton(type);
                boolean first = true;
                for (AuthorityType subType : authorityTypes) {
                    if (first) {
                        first = false;
                    } else {
                        query.append(" OR ");
                    }
                    query.append("@")
                            .append(SearchLanguageConversion.escapeLuceneQuery(
                                    "{" + ContentModel.PROP_AUTHORITY_NAME.getNamespaceURI() + "}"
                                            + ISO9075.encode(ContentModel.PROP_AUTHORITY_NAME.getLocalName())))
                            .append(":\"");
                    query.append(
                            getName(subType, SearchLanguageConversion.escapeLuceneQuery(displayNamePattern)))
                            .append("\"");

                }
            } else {
                query.append("@")
                        .append(SearchLanguageConversion.escapeLuceneQuery(
                                "{" + ContentModel.PROP_AUTHORITY_NAME.getNamespaceURI() + "}"
                                        + ISO9075.encode(ContentModel.PROP_AUTHORITY_NAME.getLocalName())))
                        .append(":\"");
                query.append(getName(type, SearchLanguageConversion.escapeLuceneQuery(displayNamePattern)))
                        .append("\"");
            }
            query.append(" OR @")
                    .append(SearchLanguageConversion.escapeLuceneQuery(
                            "{" + ContentModel.PROP_AUTHORITY_DISPLAY_NAME.getNamespaceURI() + "}"
                                    + ISO9075.encode(ContentModel.PROP_AUTHORITY_DISPLAY_NAME.getLocalName())))
                    .append(":\"").append(SearchLanguageConversion.escapeLuceneQuery(displayNamePattern))
                    .append("\")");
        }
        if (type == null) {
            query.append("))");
        }
    }
    if (parentAuthority != null) {
        if (immediate) {
            // use PARENT
            NodeRef parentAuthorityNodeRef = getAuthorityNodeRefOrNull(parentAuthority);
            if (parentAuthorityNodeRef != null) {
                query.append(" AND PARENT:\"")
                        .append(SearchLanguageConversion.escapeLuceneQuery(parentAuthorityNodeRef.toString()))
                        .append("\"");
            } else {
                throw new UnknownAuthorityException("An authority was not found for " + parentAuthority);
            }
        } else {
            // use PATH
            query.append(" AND PATH:\"/sys:system/sys:authorities/cm:").append(ISO9075.encode(parentAuthority));
            query.append("//*\"");
        }
    }
    if (zoneName != null) {
        // Zones are all direct links to those within so it is safe to use PARENT to look them up
        NodeRef zoneNodeRef = getZone(zoneName);
        if (zoneNodeRef != null) {
            query.append(" AND PARENT:\"")
                    .append(SearchLanguageConversion.escapeLuceneQuery(zoneNodeRef.toString())).append("\"");
        } else {
            throw new UnknownAuthorityException("A zone was not found for " + zoneName);
        }
    }
    sp.setQuery(query.toString());
    sp.setMaxItems(100);
    ResultSet rs = null;
    try {
        rs = searchService.query(sp);

        for (ResultSetRow row : rs) {
            NodeRef nodeRef = row.getNodeRef();
            QName idProp = dictionaryService.isSubClass(nodeService.getType(nodeRef),
                    ContentModel.TYPE_AUTHORITY_CONTAINER) ? ContentModel.PROP_AUTHORITY_NAME
                            : ContentModel.PROP_USERNAME;
            addAuthorityNameIfMatches(authorities, DefaultTypeConverter.INSTANCE.convert(String.class,
                    nodeService.getProperty(nodeRef, idProp)), type, pattern);
        }

        // If we asked for root authorities, we must do an intersection with the set of root authorities
        if (rootAuthorities != null) {
            authorities.retainAll(rootAuthorities);
        }

        if (start != null) {
            logger.debug("findAuthorities: " + authorities.size() + " items in "
                    + (System.currentTimeMillis() - start) + " msecs [type=" + type + ",zone=" + zoneName
                    + ",parent=" + parentAuthority + ",immediate=" + immediate + ",filter=" + displayNamePattern
                    + "]");
        }

        return authorities;
    } finally {
        if (rs != null) {
            rs.close();
        }
    }
}

From source file:com.clustercontrol.performance.util.code.CollectorItemCodeTable.java

/**
 * ??facilityId?????????ID????/*from   ww  w.ja va  2  s  .  com*/
 * 
 * @param facilityId
 * @return
 * @throws HinemosUnknown
 */
private static Set<CollectorItemCodeMstData> getEnableCodeSet(String facilityId) throws HinemosUnknown {
    m_log.debug("getEnableCodeSet() facilityId = " + facilityId);

    // ID?????????????????
    Set<CollectorItemCodeMstData> enableItemCodeSetInEveryNode = null;

    // ID????NULL?????????
    if (facilityId == null || "".equals(facilityId)) {
        m_log.debug("getEnableCodeSet() codeSet is 0");
        return enableItemCodeSetInEveryNode;
    }

    try {
        // ???SessionBean
        RepositoryControllerBean bean = new RepositoryControllerBean();

        ////
        // ???
        ////
        List<String> nodeList = null;
        if (bean.isNode(facilityId)) { // ???
            m_log.debug("getEnableCodeSet() facilityId is node");

            // ??
            nodeList = new ArrayList<String>();
            nodeList.add(facilityId);
        } else { // ???
            m_log.debug("getEnableCodeSet() facilityId is scope");

            // ??????ID??
            nodeList = bean.getNodeFacilityIdList(facilityId, null, RepositoryControllerBean.ALL);
        }

        ////
        // ???????ID?
        ////
        Set<PlatformIdAndSubPlatformId> platformSet = new HashSet<PlatformIdAndSubPlatformId>();
        for (String nodeId : nodeList) {
            m_log.debug("getEnableCodeSet() target node  = " + nodeId);
            NodeInfo node = bean.getNode(nodeId);

            platformSet
                    .add(new PlatformIdAndSubPlatformId(node.getPlatformFamily(), node.getSubPlatformFamily()));
        }

        ////
        // ?????????ID??
        ////
        for (PlatformIdAndSubPlatformId platform : platformSet) {

            if (m_log.isDebugEnabled()) {
                m_log.debug("getEnableCodeSet() " + "platformId = " + platform.getPlatformId()
                        + ", subPlatformId = " + platform.getSubPlatformId());
            }

            // ???????
            Collection<CollectorCategoryCollectMstEntity> collects;
            // ????????
            List<CollectorItemCalcMethodMstEntity> calsMethods;
            try {
                collects = QueryUtil.getCollectorCategoryCollectMstByPlatformIdSubPlatformId(
                        platform.getPlatformId(), platform.getSubPlatformId());
                calsMethods = QueryUtil.getCollectorItemCalcMethodMstByPlatformIdSubPlatformId(
                        platform.getPlatformId(), platform.getSubPlatformId());
                if (m_log.isDebugEnabled()) {
                    m_log.debug("getEnableCodeSet() " + "platformId = " + platform.getPlatformId()
                            + ", subPlatformId = " + platform.getSubPlatformId()
                            + ", CollectorCategoryCollectMstEntity size = " + collects.size()
                            + ", CollectorItemCalcMethodMstEntity size = " + calsMethods.size());
                }
                // VM???????????????????????
                // ???????? ?????????
                if (!platform.getSubPlatformId().isEmpty()) {
                    Collection<CollectorCategoryCollectMstEntity> physicalCollects = QueryUtil
                            .getCollectorCategoryCollectMstByPlatformIdSubPlatformId(platform.getPlatformId(),
                                    "");
                    Collection<CollectorItemCalcMethodMstEntity> physicalCalsMethods = QueryUtil
                            .getCollectorItemCalcMethodMstByPlatformIdSubPlatformId(platform.getPlatformId(),
                                    "");
                    collects.addAll(physicalCollects);
                    calsMethods.addAll(physicalCalsMethods);
                    if (m_log.isDebugEnabled()) {
                        m_log.debug("getEnableCodeSet() " + "platformId = " + platform.getPlatformId()
                                + ", physical platform, " + ", CollectorCategoryCollectMstEntity size = "
                                + physicalCollects.size() + ", CollectorItemCalcMethodMstEntity size = "
                                + physicalCalsMethods.size());
                    }
                }
            } catch (Exception e) {
                m_log.warn("getEnableCodeSet() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
                return null;
            }

            // categoryCode?collectMethod??
            HashMap<String, String> categoryMap = new HashMap<String, String>();
            for (CollectorCategoryCollectMstEntity collect : collects) {
                m_log.debug("getEnableCodeSet() add map categoryCode = " + collect.getId().getCategoryCode()
                        + ", collectMethod = " + collect.getCollectMethod());
                categoryMap.put(collect.getId().getCategoryCode(), collect.getCollectMethod());
            }

            // ????????????Set
            HashSet<CollectorItemCodeMstData> enableItemCodeSetByPlatform = new HashSet<CollectorItemCodeMstData>();

            // ????????????????????????
            for (CollectorItemCalcMethodMstEntity calcBean : calsMethods) {

                CollectorItemCodeMstData codeBean;
                try {
                    m_log.debug("getEnableCodeSet() search itemCode = " + calcBean.getId().getItemCode());
                    codeBean = CollectorMasterCache.getCategoryCodeMst(calcBean.getId().getItemCode());
                    if (codeBean == null) {
                        // ???????
                        m_log.warn("getEnableCodeSet() codeBean is null. id = " + calcBean.getId());
                        return null;
                    }
                } catch (Exception e) {
                    m_log.warn("getEnableCodeSet() : " + e.getClass().getSimpleName() + ", " + e.getMessage(),
                            e);
                    return null;
                }

                // ?????????????
                // ??????????Set??
                if (categoryMap.get(codeBean.getCategoryCode()) != null && categoryMap
                        .get(codeBean.getCategoryCode()).equals(calcBean.getId().getCollectMethod())) {
                    // ??DTO?
                    CollectorItemCodeMstData codeData = new CollectorItemCodeMstData(codeBean.getItemCode(),
                            codeBean.getCategoryCode(), codeBean.getParentItemCode(), codeBean.getItemName(),
                            codeBean.getMeasure(), codeBean.isDeviceSupport(), codeBean.getDeviceType(),
                            codeBean.isGraphRange());
                    m_log.debug("getEnableCodeSet() add itemCode = " + calcBean.getId().getItemCode());
                    enableItemCodeSetByPlatform.add(codeData);
                }

            }
            // ???????????????AND?
            // ????????????????????
            // ???????????????????
            // ???????AND?set.retainAll
            // ??????????????????????????
            if (enableItemCodeSetInEveryNode == null) {
                m_log.debug("getEnableCodeSet() enableCodeSetInEveryNode is null");
                enableItemCodeSetInEveryNode = enableItemCodeSetByPlatform;
            }
            enableItemCodeSetInEveryNode.retainAll(enableItemCodeSetByPlatform);
            m_log.debug("getEnableCodeSet() enableCodeSetInEveryNode size = "
                    + enableItemCodeSetInEveryNode.size());
        }

    } catch (FacilityNotFound e) {
        m_log.debug("getEnableCodeSet " + facilityId);
    } catch (HinemosUnknown e) {
        throw e;
    } catch (Exception e) {
        m_log.warn("getEnableCodeSet() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
        throw new HinemosUnknown(e.getMessage(), e);
    }

    // 1??????0?Set?
    if (enableItemCodeSetInEveryNode == null) {
        enableItemCodeSetInEveryNode = new HashSet<CollectorItemCodeMstData>();
    }
    return enableItemCodeSetInEveryNode;
}