Example usage for java.util HashSet addAll

List of usage examples for java.util HashSet addAll

Introduction

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

Prototype

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

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:it.cnr.icar.eric.client.xml.registry.infomodel.RegistryObjectImpl.java

/**
 * RIM Composed objects are composed objects as defined by RIM.
 * Composed objects are composed objects as defined by JAXR.
 * JAXR defines more composed objects than RIM does.
 *///from   www.  ja  v a2 s  .co  m
@SuppressWarnings({ "rawtypes", "unchecked" })
public HashSet getRIMComposedObjects() throws JAXRException {
    HashSet composedObjects = super.getRIMComposedObjects();

    Collection classifications = getClassifications();
    composedObjects.addAll(classifications);

    Collection extIds = getExternalIdentifiers();
    composedObjects.addAll(extIds);

    Collection slotIds = getSlots();
    composedObjects.addAll(slotIds);

    return composedObjects;
}

From source file:it.cnr.icar.eric.client.xml.registry.infomodel.RegistryObjectImpl.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public HashSet getComposedObjects() throws JAXRException {
    HashSet composedObjects = super.getComposedObjects();

    Collection classifications = getClassifications();
    composedObjects.addAll(classifications);

    Collection extIds = getExternalIdentifiers();
    composedObjects.addAll(extIds);/*from w  ww.  j  a  v  a 2 s. c  om*/

    Collection extLinks = getExternalLinks();
    composedObjects.addAll(extLinks);

    composedObjects.addAll(getAssociationsAndAssociatedObjects());

    Collection slotIds = getSlots();
    composedObjects.addAll(slotIds);

    return composedObjects;
}

From source file:com.twitter.pig.backend.hadoop.executionengine.tez.TezExecutionEngine.java

@SuppressWarnings("unchecked")
public PhysicalPlan compile(LogicalPlan plan, Properties properties) throws FrontendException {
    if (plan == null) {
        int errCode = 2041;
        String msg = "No Plan to compile";
        throw new FrontendException(msg, errCode, PigException.BUG);
    }//from  w  w  w . j ava2 s .  co  m

    newPreoptimizedPlan = new LogicalPlan(plan);

    if (pigContext.inIllustrator) {
        // disable all PO-specific optimizations
        POOptimizeDisabler pod = new POOptimizeDisabler(plan);
        pod.visit();
    }

    UidResetter uidResetter = new UidResetter(plan);
    uidResetter.visit();

    SchemaResetter schemaResetter = new SchemaResetter(plan, true /*skip duplicate uid check*/ );
    schemaResetter.visit();

    HashSet<String> disabledOptimizerRules;
    try {
        disabledOptimizerRules = (HashSet<String>) ObjectSerializer
                .deserialize(pigContext.getProperties().getProperty(PigImplConstants.PIG_OPTIMIZER_RULES_KEY));
    } catch (IOException ioe) {
        int errCode = 2110;
        String msg = "Unable to deserialize optimizer rules.";
        throw new FrontendException(msg, errCode, PigException.BUG, ioe);
    }
    if (disabledOptimizerRules == null) {
        disabledOptimizerRules = new HashSet<String>();
    }

    String pigOptimizerRulesDisabled = this.pigContext.getProperties()
            .getProperty(PigConstants.PIG_OPTIMIZER_RULES_DISABLED_KEY);
    if (pigOptimizerRulesDisabled != null) {
        disabledOptimizerRules.addAll(Lists.newArrayList((Splitter.on(",").split(pigOptimizerRulesDisabled))));
    }

    if (pigContext.inIllustrator) {
        disabledOptimizerRules.add("MergeForEach");
        disabledOptimizerRules.add("PartitionFilterOptimizer");
        disabledOptimizerRules.add("LimitOptimizer");
        disabledOptimizerRules.add("SplitFilter");
        disabledOptimizerRules.add("PushUpFilter");
        disabledOptimizerRules.add("MergeFilter");
        disabledOptimizerRules.add("PushDownForEachFlatten");
        disabledOptimizerRules.add("ColumnMapKeyPrune");
        disabledOptimizerRules.add("AddForEach");
        disabledOptimizerRules.add("GroupByConstParallelSetter");
    }

    StoreAliasSetter storeAliasSetter = new StoreAliasSetter(plan);
    storeAliasSetter.visit();

    // run optimizer
    LogicalPlanOptimizer optimizer = new LogicalPlanOptimizer(plan, 100, disabledOptimizerRules);
    optimizer.optimize();

    // compute whether output data is sorted or not
    SortInfoSetter sortInfoSetter = new SortInfoSetter(plan);
    sortInfoSetter.visit();

    if (!pigContext.inExplain) {
        // Validate input/output file. Currently no validation framework in
        // new logical plan, put this validator here first.
        // We might decide to move it out to a validator framework in future
        InputOutputFileValidator validator = new InputOutputFileValidator(plan, pigContext);
        validator.validate();
    }

    // translate new logical plan to physical plan
    LogToPhyTranslationVisitor translator = new LogToPhyTranslationVisitor(plan);

    translator.setPigContext(pigContext);
    translator.visit();
    newLogToPhyMap = translator.getLogToPhyMap();
    return translator.getPhysicalPlan();
}

From source file:org.egov.works.services.WorksService.java

/**
 * NOTE --- THIS API IS USED ONLY FOR WORK PROGRESS ABSTRACT REPORT BY DEPARTMENT IN WORKS MODULE
 *
 * @description -This method returns the approved CJV count and sum of CJVs amount for the approved CJVs made till date for a
 * list of Project codes for which there is a final bill created for it. Project code Ids present in the temporary table
 * WorkProgressProjectCode for a particular uuid are only considered NOTE --- ASSUMPTION IS THERE WILL BE ONLY 1 FINAL BILL
 * FOR AN ESTIMATE/*  w ww  .ja v a 2s  . c  o m*/
 * @param uuid - Only project codes ids associated with this uuid are considered
 * @return - List of Map of Maps. The outer map's key is the department name Inner map's keys "amount" and "count" represent
 * sum of CJVs amount and approved CJV count
 * @return - Null is returned in the case of no data
 * @throws ApplicationException - If anyone of the parameters is null or the ProjectCode list passed is empty.
 */
public List<Map<String, Map<String, BigDecimal>>> getTotalCJVCountAndAmounts(final String uuid)
        throws ApplicationException {

    Map<String, Map<String, BigDecimal>> resultMap = null;
    Map<String, BigDecimal> simpleMap = null;
    List<Object[]> payQueryResult;
    List<Object[]> countQueryResult;
    final List<Map<String, Map<String, BigDecimal>>> resultList = new ArrayList<Map<String, Map<String, BigDecimal>>>();

    final String payQuery = " select dept.dept_name , nvl(sum(bp.debitamount),0)  FROM "
            + " eg_billregister br,eg_billdetails bd, eg_billpayeedetails bp,voucherheader vh,eg_billregistermis ms , eg_department dept "
            + " WHERE br.id=bd.billid and bd.id=bp.BILLDETAILID and vh.id=ms.VOUCHERHEADERID and ms.BILLID=br.id and bp.pc_department=dept.id_dept  and vh.name='Contractor Journal'  "
            + " and br.STATUSID in(select id from egw_status where lower(code)='approved' and "
            + " moduletype in('CONTRACTORBILL')) " + " and bd.DEBITAMOUNT>0  and vh.STATUS="
            + FinancialConstants.CREATEDVOUCHERSTATUS
            + " and bp.ACCOUNTDETAILTYPEID= (SELECT id FROM accountdetailtype "
            + " WHERE name ='PROJECTCODE' AND description='PROJECTCODE' ) and (bp.ACCOUNTDETAILKEYID in(SELECT PC_ID FROM EGW_WORKPROGRESS_PROJECT_CODE WHERE UUID like '"
            + uuid + "'))"
            + " and bp.accountdetailkeyid in ( select bp1.ACCOUNTDETAILKEYID FROM eg_billregister br1, "
            + " eg_billdetails bd1, eg_billpayeedetails bp1 ,voucherheader vh1,eg_billregistermis ms1  WHERE br1.id =bd1.billid AND bd1.id =bp1.BILLDETAILID  "
            + "  and vh1.id=ms1.VOUCHERHEADERID and ms1.BILLID=br1.id and vh1.name='Contractor Journal' and vh1.STATUS="
            + FinancialConstants.CREATEDVOUCHERSTATUS
            + " AND br1.STATUSID IN (SELECT id FROM egw_status WHERE lower(code)='approved' AND moduletype  IN('CONTRACTORBILL')) "
            + " and br1.billtype in ('FinalBill', 'Final Bill') and bp1.ACCOUNTDETAILKEYID = bp.ACCOUNTDETAILKEYID "
            + " and bp1.ACCOUNTDETAILTYPEID=bp.ACCOUNTDETAILTYPEID ) group by dept.dept_name  order by dept.dept_name  ";

    final String countQuery = " select dept.dept_name , count(vh.id) FROM "
            + " eg_billregister br,eg_billdetails bd, eg_billpayeedetails bp,voucherheader vh,eg_billregistermis ms, eg_department dept  "
            + " WHERE br.id=bd.billid and bd.id=bp.BILLDETAILID and vh.id=ms.VOUCHERHEADERID and ms.BILLID=br.id and bp.pc_department=dept.id_dept  and vh.name='Contractor Journal' "
            + " and br.billtype in ('FinalBill', 'Final Bill') "
            + " and br.STATUSID in(select id from egw_status where lower(code)='approved' and "
            + " moduletype in('CONTRACTORBILL')) " + " and bd.DEBITAMOUNT>0  and vh.STATUS="
            + FinancialConstants.CREATEDVOUCHERSTATUS
            + " and bp.ACCOUNTDETAILTYPEID= (SELECT id FROM accountdetailtype "
            + " WHERE name ='PROJECTCODE' AND description='PROJECTCODE' ) and (bp.ACCOUNTDETAILKEYID in(SELECT PC_ID FROM EGW_WORKPROGRESS_PROJECT_CODE WHERE UUID like '"
            + uuid + "'))  group by dept.dept_name order by dept.dept_name ";

    payQueryResult = persistenceService.getSession().createSQLQuery(payQuery).list();
    countQueryResult = persistenceService.getSession().createSQLQuery(countQuery).list();
    final List<String> deptNameList = new ArrayList<String>();
    if (payQueryResult != null && payQueryResult.size() > 0)
        for (Integer i = 0; i < payQueryResult.size(); i++)
            deptNameList.add(payQueryResult.get(i)[0].toString());
    if (countQueryResult != null && countQueryResult.size() > 0)
        for (Integer i = 0; i < countQueryResult.size(); i++)
            deptNameList.add(countQueryResult.get(i)[0].toString());
    if (deptNameList == null || !(deptNameList.size() > 0))
        return null;
    // To remove duplicates
    final HashSet<String> tempSet = new HashSet<String>();
    tempSet.addAll(deptNameList);
    deptNameList.clear();
    deptNameList.addAll(tempSet);
    final BigDecimal[] payArray = new BigDecimal[deptNameList.size()];
    final BigDecimal[] countArray = new BigDecimal[deptNameList.size()];
    for (Integer i = 0; i < deptNameList.size(); i++) {
        payArray[i] = BigDecimal.ZERO;
        countArray[i] = BigDecimal.ZERO;
    }
    String deptName = null;
    Integer index = null;
    Integer i = null;
    for (i = 0; i < payQueryResult.size(); i++) {
        deptName = payQueryResult.get(i)[0].toString();
        index = deptNameList.indexOf(deptName);
        payArray[index] = new BigDecimal(payQueryResult.get(i)[1].toString());
    }
    for (i = 0; i < countQueryResult.size(); i++) {
        deptName = countQueryResult.get(i)[0].toString();
        index = deptNameList.indexOf(deptName);
        countArray[index] = new BigDecimal(countQueryResult.get(i)[1].toString());
    }
    for (i = 0; i < deptNameList.size(); i++) {
        deptName = deptNameList.get(i);
        simpleMap = new HashMap<String, BigDecimal>();
        simpleMap.put("amount", payArray[i]);
        simpleMap.put("count", countArray[i]);
        resultMap = new HashMap<String, Map<String, BigDecimal>>();
        resultMap.put(deptName, simpleMap);
        resultList.add(resultMap);
    }
    return resultList;
}

From source file:org.egov.works.services.WorksService.java

/**
 * NOTE --- THIS API IS USED ONLY FOR Works Report 2 dashboard BY DEPARTMENT IN WORKS MODULE
 *
 * @description -This method returns the approved CJV count and sum of CJVs amount for the approved CJVs made till date for a
 * list of Spill over Project codes for which there is a final bill created for it in current year. Project code Ids present
 * in the temporary table WorkProgProjCodeSpillOver for a particular uuid are only considered NOTE --- ASSUMPTION IS THERE
 * WILL BE ONLY 1 FINAL BILL FOR AN ESTIMATE
 * @param uuid - Only spill over project codes ids associated with this uuid are considered
 * @return - List of Map of Maps. The outer map's key is the department name Inner map's keys "amount" and "count" represent
 * sum of CJVs amount and approved Final CJV count
 * @return - Null is returned in the case of no data
 * @throws ApplicationException - If anyone of the parameters is null or the ProjectCode list passed is empty.
 *///from   w ww . ja  v  a2  s.co m
public List<Map<String, Map<String, BigDecimal>>> getCJVCountAndAmountsForSpillOver(final String uuid,
        final Date fromDate, final Date toDate) throws ApplicationException {

    Map<String, Map<String, BigDecimal>> resultMap = null;
    Map<String, BigDecimal> simpleMap = null;
    List<Object[]> payQueryResult;
    List<Object[]> countQueryResult;
    final List<Map<String, Map<String, BigDecimal>>> resultList = new ArrayList<Map<String, Map<String, BigDecimal>>>();

    final String payQuery = " select dept.dept_name , nvl(sum(bp.debitamount),0)  FROM "
            + " eg_billregister br,eg_billdetails bd, eg_billpayeedetails bp,voucherheader vh,eg_billregistermis ms , eg_department dept "
            + " WHERE br.id=bd.billid and bd.id=bp.BILLDETAILID and vh.id=ms.VOUCHERHEADERID and ms.BILLID=br.id and bp.pc_department=dept.id_dept  and vh.name='Contractor Journal'  "
            + " and br.STATUSID in(select id from egw_status where lower(code)='approved' and "
            + " moduletype in('CONTRACTORBILL')) " + " and br.billdate between '"
            + dateFormatter.format(fromDate) + "' and '" + dateFormatter.format(toDate) + "'"
            + " and bd.DEBITAMOUNT>0  and vh.STATUS=" + FinancialConstants.CREATEDVOUCHERSTATUS
            + " and bp.ACCOUNTDETAILTYPEID= (SELECT id FROM accountdetailtype "
            + " WHERE name ='PROJECTCODE' AND description='PROJECTCODE' ) and (bp.ACCOUNTDETAILKEYID in(SELECT PC_ID FROM EGW_WRKPROG_PROJCODE_SPILLOVER WHERE UUID like '"
            + uuid + "'))"
            + " and bp.accountdetailkeyid in ( select bp1.ACCOUNTDETAILKEYID FROM eg_billregister br1, "
            + " eg_billdetails bd1, eg_billpayeedetails bp1 ,voucherheader vh1,eg_billregistermis ms1  WHERE br1.id =bd1.billid AND bd1.id =bp1.BILLDETAILID  "
            + "  and vh1.id=ms1.VOUCHERHEADERID and ms1.BILLID=br1.id and vh1.name='Contractor Journal' and vh1.STATUS="
            + FinancialConstants.CREATEDVOUCHERSTATUS
            + " AND br1.STATUSID IN (SELECT id FROM egw_status WHERE lower(code)='approved' AND moduletype  IN('CONTRACTORBILL')) "
            + " and br1.billtype in ('FinalBill', 'Final Bill') and bp1.ACCOUNTDETAILKEYID = bp.ACCOUNTDETAILKEYID "
            + " and bp1.ACCOUNTDETAILTYPEID=bp.ACCOUNTDETAILTYPEID ) group by dept.dept_name  order by dept.dept_name  ";

    final String countQuery = " select dept.dept_name , count(vh.id) FROM "
            + " eg_billregister br,eg_billdetails bd, eg_billpayeedetails bp,voucherheader vh,eg_billregistermis ms, eg_department dept  "
            + " WHERE br.id=bd.billid and bd.id=bp.BILLDETAILID and vh.id=ms.VOUCHERHEADERID and ms.BILLID=br.id and bp.pc_department=dept.id_dept  and vh.name='Contractor Journal' "
            + " and br.billtype in ('FinalBill', 'Final Bill') "
            + " and br.STATUSID in(select id from egw_status where lower(code)='approved' and "
            + " moduletype in('CONTRACTORBILL')) " + " and br.billdate between '"
            + dateFormatter.format(fromDate) + "' and '" + dateFormatter.format(toDate) + "'"
            + " and bd.DEBITAMOUNT>0  and vh.STATUS=" + FinancialConstants.CREATEDVOUCHERSTATUS
            + " and bp.ACCOUNTDETAILTYPEID= (SELECT id FROM accountdetailtype "
            + " WHERE name ='PROJECTCODE' AND description='PROJECTCODE' ) and (bp.ACCOUNTDETAILKEYID in(SELECT PC_ID FROM EGW_WRKPROG_PROJCODE_SPILLOVER WHERE UUID like '"
            + uuid + "'))  group by dept.dept_name order by dept.dept_name ";

    payQueryResult = persistenceService.getSession().createSQLQuery(payQuery).list();
    countQueryResult = persistenceService.getSession().createSQLQuery(countQuery).list();
    final List<String> deptNameList = new ArrayList<String>();
    if (payQueryResult != null && payQueryResult.size() > 0)
        for (Integer i = 0; i < payQueryResult.size(); i++)
            deptNameList.add(payQueryResult.get(i)[0].toString());
    if (countQueryResult != null && countQueryResult.size() > 0)
        for (Integer i = 0; i < countQueryResult.size(); i++)
            deptNameList.add(countQueryResult.get(i)[0].toString());
    if (deptNameList == null || !(deptNameList.size() > 0))
        return null;
    // To remove duplicates
    final HashSet<String> tempSet = new HashSet<String>();
    tempSet.addAll(deptNameList);
    deptNameList.clear();
    deptNameList.addAll(tempSet);
    final BigDecimal[] payArray = new BigDecimal[deptNameList.size()];
    final BigDecimal[] countArray = new BigDecimal[deptNameList.size()];
    for (Integer i = 0; i < deptNameList.size(); i++) {
        payArray[i] = BigDecimal.ZERO;
        countArray[i] = BigDecimal.ZERO;
    }
    String deptName = null;
    Integer index = null;
    Integer i = null;
    for (i = 0; i < payQueryResult.size(); i++) {
        deptName = payQueryResult.get(i)[0].toString();
        index = deptNameList.indexOf(deptName);
        payArray[index] = new BigDecimal(payQueryResult.get(i)[1].toString());
    }
    for (i = 0; i < countQueryResult.size(); i++) {
        deptName = countQueryResult.get(i)[0].toString();
        index = deptNameList.indexOf(deptName);
        countArray[index] = new BigDecimal(countQueryResult.get(i)[1].toString());
    }
    for (i = 0; i < deptNameList.size(); i++) {
        deptName = deptNameList.get(i);
        simpleMap = new HashMap<String, BigDecimal>();
        simpleMap.put("amount", payArray[i]);
        simpleMap.put("count", countArray[i]);
        resultMap = new HashMap<String, Map<String, BigDecimal>>();
        resultMap.put(deptName, simpleMap);
        resultList.add(resultMap);
    }
    return resultList;
}

From source file:com.googlecode.fascinator.portal.process.RecordProcessor.java

/**
 * 'pre' - processing method.//  w w w. j ava 2s .co m
 * 
 * The Solr Query is executed and the resulting ID HashSet is stored on the
 * dataMap as the 'outputKey', along with any entries from 'includeList'
 * config entry. To manually process a certain record(s), add the id on the
 * 'includeList'. Processing will read the 'lastRun' config entry and pulls
 * records since then. <br/>
 * 
 * @param id
 * @param outputKey
 * @param configFilePath
 * @param dataMap
 * @return
 * @throws Exception
 */
private boolean getRecords(String id, String outputKey, String configFilePath, HashMap<String, Object> dataMap)
        throws Exception {
    Indexer indexer = (Indexer) dataMap.get("indexer");
    JsonSimple config = new JsonSimple(new File(configFilePath));
    String solrQuery = config.getString("", "query");
    String lastRun = config.getString(null, "lastrun");
    solrQuery += (lastRun != null ? " AND create_timestamp:[" + lastRun + " TO NOW]" : "");
    log.debug("Using solrQuery:" + solrQuery);
    SearchRequest searchRequest = new SearchRequest(solrQuery);
    int start = 0;
    int pageSize = 10;
    searchRequest.setParam("start", "" + start);
    searchRequest.setParam("rows", "" + pageSize);
    ByteArrayOutputStream result = new ByteArrayOutputStream();
    indexer.search(searchRequest, result);
    SolrResult resultObject = new SolrResult(result.toString());
    int numFound = resultObject.getNumFound();
    log.debug("Number found:" + numFound);
    HashSet<String> newRecords = new HashSet<String>();
    while (true) {
        List<SolrDoc> results = resultObject.getResults();
        for (SolrDoc docObject : results) {
            String oid = docObject.getString(null, "id");
            if (oid != null) {
                log.debug("Record found: " + oid);
                newRecords.add(oid);
            } else {
                log.debug("Record returned but has no id.");
                log.debug(docObject.toString());
            }
        }
        start += pageSize;
        if (start > numFound) {
            break;
        }
        searchRequest.setParam("start", "" + start);
        result = new ByteArrayOutputStream();
        indexer.search(searchRequest, result);
        resultObject = new SolrResult(result.toString());
    }
    // get the exception list..
    JSONArray includedArr = config.getArray("includeList");
    if (includedArr != null && includedArr.size() > 0) {
        newRecords.addAll(includedArr);
    }
    dataMap.put(outputKey, newRecords);
    return true;
}

From source file:com.onegravity.contactpicker.core.ContactPickerActivity.java

private void onDone() {

    HashSet<String> phoneHash = new HashSet<>();

    // return only checked contacts
    HashSet<Long> contactHash = new HashSet<>();
    if (mContacts != null) {
        for (Contact contact : mContacts) {
            if (contact.isChecked()) {
                phoneHash.addAll(contact.getPhones());
                contactHash.add(contact.getId());
            }/* ww  w  . j a  v  a 2  s.c o m*/
        }
    }

    // return only checked groups
    HashSet<Long> groupHash = new HashSet<>();
    if (mGroups != null) {
        for (Group group : mGroups) {
            if (group.isChecked()) {
                groupHash.add(group.getId());
            }
        }
    }

    ArrayList<Long> contactList = new ArrayList<>(contactHash);
    ArrayList<Long> groupList = new ArrayList<>(groupHash);
    ArrayList<String> phoneList = new ArrayList<>(phoneHash);

    Intent data = new Intent();
    data.putExtra(RESULT_CONTACT_DATA, contactList);
    data.putExtra(RESULT_GROUP_DATA, groupList);
    data.putExtra(RESULT_PHONE_DATA, phoneList);

    setResult(Activity.RESULT_OK, data);
    finish();
}

From source file:com.healthcit.cacure.businessdelegates.QuestionAnswerManager.java

@Transactional
public List<FormElement> buildNewQuestions(String[][] questionSet, int searchCriteria) {
    List<FormElement> newElements = new ArrayList<FormElement>();
    Map<String, DataElement> dataElements = new HashMap<String, DataElement>();
    int numElements = questionSet.length;
    String[] questionIdList = new String[numElements];
    String[] answerTypeList = new String[numElements];
    String[] deletedAnswerValuesList = new String[numElements];
    for (int i = 0; i < numElements; ++i) {
        questionIdList[i] = questionSet[i][0];
        answerTypeList[i] = questionSet[i][1];
        if (questionSet[i].length > 2)
            deletedAnswerValuesList[i] = questionSet[i][2];
    }//from w ww. j a v  a  2s  . c  o m

    for (int i = 0; i < numElements; ++i) {

        String uuid = questionIdList[i];

        // The following 2 variables are not used. I am leaving them in case the accessors are used 
        // to load lazy collections - LK
        String answerType = answerTypeList[i];
        HashSet<String> deletedAnswerValues = new HashSet<String>();
        if (StringUtils.isNotBlank(deletedAnswerValuesList[i])) {
            deletedAnswerValues.addAll(Arrays.asList(deletedAnswerValuesList[i].split("\\s*,\\s*")));
        }

        if (searchCriteria == FormElementSearchCriteria.SEARCH_BY_CADSR_TEXT // CADSR Text Search
                || searchCriteria == FormElementSearchCriteria.SEARCH_BY_CADSR_CART_USER) // CADSR Cart User Search
        {
            if (i == 0)
                dataElements = cadsrManager.findCADSRQuestionsById(StringUtils.join(questionIdList, SPLITTER));
            DataElement dataElement = dataElements.get(uuid);
            if (dataElement != null) {
                FormElement newElement;
                AnswerType answerTypeEnumEntry = AnswerType.valueOf(answerType);
                newElement = cadsrManager.transformCADSRQuestion(dataElement, answerTypeEnumEntry,
                        deletedAnswerValues);
                newElements.add(newElement);
            }
        } else // local
        {
            LinkElement linkElement = new LinkElement();
            FormElement source = linkDao.getLinkSource(uuid);
            linkElement.setLearnMore(source.getLearnMore());
            linkElement.setVisible(source.isVisible());
            linkElement.setRequired(source.isRequired());
            linkElement.setReadonly(source.isReadonly());
            linkElement.setDescription(source.getDescription());
            linkElement.setSource(source);
            newElements.add(linkElement);
        }
    }
    modifyShortNames(newElements);
    return newElements;
}

From source file:ch.unil.genescore.pathway.GeneSetLibrary.java

License:asdf

public void computeApproxPathwayCorrelation() {

    DenseMatrix corMat = new DenseMatrix(geneSets_.size(), geneSets_.size());
    for (int i = 0; i < geneSets_.size(); i++) {
        GeneSet leftSet = geneSets_.get(i);
        double leftSize = leftSet.genes_.size();
        for (int j = 0; j < geneSets_.size(); j++) {
            GeneSet rightSet = geneSets_.get(j);
            double rightSize = rightSet.genes_.size();
            HashSet<Gene> unpackedMetaGenes = new HashSet<Gene>();
            HashSet<Gene> allRightGenes = new HashSet<Gene>();
            if (null != rightSet.getMetaGenes())
                for (MetaGene mg : rightSet.getMetaGenes()) {
                    unpackedMetaGenes.addAll(mg.getGenes());
                }/*w  ww  .  ja  v a  2s  .  c  o m*/

            allRightGenes.addAll(unpackedMetaGenes);
            allRightGenes.addAll(rightSet.genes_);
            allRightGenes.removeAll(rightSet.getMetaGenes());

            HashSet<Gene> copiedLeftGenes = new HashSet<Gene>(leftSet.genes_);
            copiedLeftGenes.retainAll(allRightGenes);
            double count = copiedLeftGenes.size();
            if (null != leftSet.getMetaGenes())
                for (MetaGene mg : leftSet.getMetaGenes()) {
                    TreeSet<Gene> mgSetCopy = new TreeSet<Gene>(mg.getGenes());
                    mgSetCopy.retainAll(allRightGenes);
                    if (!mgSetCopy.isEmpty()) {
                        count++;
                    }
                }
            double corr = count / Math.sqrt(leftSize * rightSize);
            corMat.set(i, j, corr);
            //corMat.set(j, i, corr);
        }
    }
    pathwayCorMat_ = corMat;
}

From source file:com.lynnlyc.web.taintanalysis.JSTaintAnalysis.java

public Set<List<Integer>> getTaintPathsTo(Integer sinkId) {
    HashSet<List<Integer>> paths = new HashSet<>();

    HashSet<Integer> taintMarks = this.getTaintMarks(sinkId);

    if (taintMarks.isEmpty()) {
        List<Integer> path = new ArrayList<>();
        path.add(sinkId);// w  ww.  ja  v a  2 s .  c  o m
        paths.add(path);
    } else {
        for (int mark : taintMarks) {
            Set<List<Integer>> prevPaths = getTaintPathsTo(mark);
            for (List<Integer> path : prevPaths) {
                path.add(sinkId);
            }
            paths.addAll(prevPaths);
        }
    }

    return paths;
}