List of usage examples for java.util Map clear
void clear();
From source file:edu.arizona.kra.institutionalproposal.negotiationlog.service.NegotiationLogMigrationServiceImpl.java
/** * When there is no IP associated, the details from the negotiation log are copied by this method into a * NegotiationUnassociatedDetail that gets associated with the Negotiation with association type "NO" * TODO: Do we want to check that the PI and SponsorAwardNumber actually exists and it's correct? * @param negotiationLog/* ww w .j a v a 2 s. c om*/ * @param negotiation * @return */ private NegotiationUnassociatedDetail buildNegotiationAssociatedDetail(NegotiationLog negotiationLog, Negotiation negotiation) { LOG.debug("Start building NegotiationUnassociatedDetail. Setting association type to NONE"); Map<String, Object> searchFields = new HashMap<String, Object>(); NegotiationAssociationType noAssociation = findNegotiationTypeByCode(NegotiationAssociationType.class, NegotiationAssociationType.NONE_ASSOCIATION, NegotiationAssociationType.NONE_ASSOCIATION); negotiation.setNegotiationAssociationType(noAssociation); negotiation.setNegotiationAssociationTypeId(noAssociation.getId()); NegotiationUnassociatedDetail detail = new NegotiationUnassociatedDetail(); detail.setNegotiation(negotiation); detail.setNegotiationId(negotiation.getNegotiationId()); String sponsorCode = negotiationLog.getSponsorCode(); LOG.debug("Finding sponsor from negotiation log sponsor code=" + sponsorCode); if (!StringUtils.isEmpty(sponsorCode)) { searchFields.put("sponsorCode", sponsorCode); List<Sponsor> sponsors = (List<Sponsor>) getBusinessObjectService().findMatching(Sponsor.class, searchFields); if (sponsors.size() > 0) { detail.setSponsor(sponsors.get(0)); detail.setSponsorCode(sponsorCode); } else LOG.debug("Could not find sponsor associated with Invalid sponsor code=" + sponsorCode); } String unitNumber = negotiationLog.getUnitNumber(); LOG.debug("Finding unit from negotiation log unit number=" + unitNumber); if (!StringUtils.isEmpty(unitNumber)) { searchFields.clear(); searchFields.put("unitNumber", unitNumber); Unit unit = getBusinessObjectService().findByPrimaryKey(Unit.class, searchFields); if (unit != null) { detail.setLeadUnit(unit); detail.setLeadUnitNumber(unit.getUnitNumber()); } else LOG.debug("Could not find lead unit associated with Invalid unit number=" + unitNumber); } //TODO Figure out if we need defaults for any of the below commented out fields //TODO detail.setPrimeSponsor(sponsor); //TODO detail.setPrimeSponsorCode(sponsor.getSponsorCode()); //TODO detail.setSubAwardOrganization(org); //TODO detail.setSubAwardOrganizationId(org.getOrganizationId()); //TODO rolodexId???detail.setPiRolodexId("306"); //TODO detail.setContactAdminPersonId("10000000001"); detail.setTitle(negotiationLog.getTitle()); detail.setPiPersonId(negotiationLog.getPiPersonId()); detail.setPiName(negotiationLog.getPiName()); detail.setSponsorAwardNumber(negotiationLog.getSponsorAwardNumber()); negotiation.setUnAssociatedDetail(detail); LOG.debug("Finished building NegotiationUnassociatedDetail."); return detail; }
From source file:gov.nih.nci.ncicb.cadsr.contexttree.service.impl.CDEBrowserTreeServiceImpl.java
private Map getFormClassificationNodes(TreeFunctions treeFunctions, TreeIdGenerator idGen, String csType, String csiType) throws Exception { Map csiByContextMap = new HashMap(); FormDAO dao = daoFactory.getFormDAO(); List allCscsi = dao.getCSCSIHierarchyByType(csType, csiType); Map csMap = new HashMap(); //this map stores the webnode for cs given cs_idseq Map csiMap = new HashMap(); Iterator iter = allCscsi.iterator(); while (iter.hasNext()) { ClassSchemeItem cscsi = (ClassSchemeItem) iter.next(); String csContextId = cscsi.getCsConteIdseq(); Map currentCsiMap = (Map) csiByContextMap.get(csContextId); if (currentCsiMap == null) { //create a classification node for this context csiMap = new HashMap(); csiByContextMap.put(csContextId, csiMap); csMap.clear(); }/* w w w .j a v a 2 s . c o m*/ String csId = cscsi.getCsIdseq(); // create classification scheme node if necessary DefaultMutableTreeNode csNode = (DefaultMutableTreeNode) csMap.get(csId); if (csNode == null) { csNode = getClassificationSchemeNode(idGen.getNewId(), cscsi, treeFunctions); csMap.put(csId, csNode); } // add csi node DefaultMutableTreeNode csiNode = getClassificationSchemeItemNode(idGen.getNewId(), cscsi, treeFunctions); String parentId = cscsi.getParentCscsiId(); DefaultMutableTreeNode parentNode = null; if (parentId != null) parentNode = (DefaultMutableTreeNode) csiMap.get(parentId); else parentNode = csNode; if (parentNode != null) parentNode.add(csiNode); csiMap.put(cscsi.getCsCsiIdseq(), csiNode); } return csiByContextMap; }
From source file:com.esd.ps.AdministratorController.java
/** * user list/*from w ww . jav a 2s. com*/ * * @param userNameCondition * @param userType * @param page * @param year * @param month * @param taskUpload * @return */ @RequestMapping(value = "/administrator", method = RequestMethod.POST) @ResponseBody public Map<String, Object> administratorPost(String userNameCondition, int userType, int page) { //logger.debug("userType:{},page:{},userNameCondition:{}", userType, page, userNameCondition); Map<String, Object> map = new HashMap<String, Object>(); SimpleDateFormat sdf = new SimpleDateFormat(Constants.DATETIME_FORMAT); List<userTrans> list = new ArrayList<userTrans>(); int totlePage = Constants.ZERO; List<user> userList = userService.getLikeUsername(userNameCondition, userType, page, Constants.ROW); int totle = userService.getCountLikeUsername(userNameCondition, userType); for (Iterator<user> iterator = userList.iterator(); iterator.hasNext();) { user user = (user) iterator.next(); userTrans trans = new userTrans(); trans.setUserId(user.getUserId()); if (user.getUserStatus()) { trans.setUserStatus(1); } else { trans.setUserStatus(0); } trans.setUsername(user.getUsername()); trans.setUsertypeenglish(userTypeService.getUserTypeName(user.getUsertype())); if (user.getCreateTime() == null) { trans.setCreateTime(""); } else { trans.setCreateTime(sdf.format(user.getCreateTime())); } if (user.getUpdateTime() == null) { trans.setUpdateTime(""); } else { trans.setUpdateTime(sdf.format(user.getUpdateTime())); } list.add(trans); } map.clear(); totlePage = (int) Math.ceil((double) totle / (double) Constants.ROW); map.put(Constants.LIST, list); map.put(Constants.TOTLE, totle); map.put(Constants.TOTLE_PAGE, totlePage); return map; }
From source file:de.bps.course.nodes.vc.provider.adobe.AdobeConnectProvider.java
@Override public boolean createModerator(Identity identity, String roomId) { if (!loginAdmin()) return false; Map<String, String> parameters = new HashMap<String, String>(); // create user parameters.put("action", "principal-update"); parameters.put("first-name", identity.getUser().getProperty(UserConstants.FIRSTNAME, null)); parameters.put("last-name", identity.getUser().getProperty(UserConstants.LASTNAME, null)); parameters.put("login", PREFIX + identity.getName()); parameters.put("password", Encoder.md5hash(identity.getName() + "@" + Settings.getApplicationName())); parameters.put("type", userType); parameters.put("has-children", "false"); Document responseDoc = getResponseDocument(sendRequest(parameters)); if (!evaluateOk(responseDoc)) { boolean exists = false; String error = evaluate(responseDoc, "/results/status[1]/attribute::code"); if (error.equals("invalid")) { error = evaluate(responseDoc, "/results[1]/status[1]/invalid/attribute::subcode"); exists = error.equals("duplicate"); }/*ww w .j a v a2s .com*/ if (!exists) return false; } // search the user String principalId = getPrincipalIdFor(identity); if (principalId == null) return false; // error case // create permissions for the meeting String scoId = getScoIdFor(roomId); if (scoId == null) return false; parameters.clear(); parameters.put("action", "permissions-update"); parameters.put("acl-id", scoId); parameters.put("principal-id", principalId); parameters.put("permission-id", "host"); String response = sendRequest(parameters); responseDoc = getResponseDocument(response); logout(); return evaluateOk(responseDoc); }
From source file:info.raack.appliancelabeler.datacollector.StepgreenTED5000ConfigurationLoader.java
private Map<String, List<Ted5000>> reloadConfigurations() { // get url for all configurations String response = ""; try {//from w ww .jav a 2 s . co m logger.debug("Requesting user TEDs"); synchronized (this) { Map<String, List<Ted5000>> allTeds = new HashMap<String, List<Ted5000>>(); // construct oauth access tokens Map<String, Map<String, OAuthConsumerToken>> userContexts = database.getOAuthTokensForAllUsers(); for (String userId : userContexts.keySet()) { logger.debug("Request TEDs for " + userId); Map<String, OAuthConsumerToken> tokenMap = userContexts.get(userId); if (tokenMap.isEmpty()) { // don't request anything with no tokens continue; } OAuthSecurityContextImpl oAuthContext = new OAuthSecurityContextImpl(); oAuthContext.setAccessTokens(tokenMap); String requestURI = String.format(tedDataPath, stepgreenBasehost, userId); try { allTeds.put(userId, oAuthRequestProcessor.processRequest(requestURI, oAuthContext, new ResponseHandler<AggregatedTeds, List<Ted5000>>() { public List<Ted5000> extractValue(AggregatedTeds ted) { return ted.getTed5000(); } })); } catch (OAuthUnauthorizedException e2) { String email = database.getUserEmailForUserId(userId); logger.warn("Could not get list of TEDS for user " + userId + " - request through oauth is unauthorized"); emailSender.sendGeneralEmail(email, "Your Stepgreen energy consumption authorization is no longer valid", "At some point in the past, you used the Stepgreen Appliance Energy Visualization tool to see detailed usage of your appliance energy use.\n\n" + "We have become unable to access your Stepgreen energy data. If you wish to continue using the tool, please visit " + energylabelerUrl + " now. " + "We will be unable to collect and provide any more energy predictions until you do so.\n\n" + "Thanks,\n" + "The Stepgreen Appliance Energy Team"); // now invalidate the tokens tokenMap.clear(); dataService.saveOAuthTokensForUserId(userId, email, tokenMap); } } return allTeds; } } catch (Exception e) { throw new RuntimeException("Could not get list of TEDs from StepGreen: received " + response, e); } }
From source file:com.intel.hadoop.hbase.dot.access.DataManipulationOps.java
/** * Update the column name ( "cf:doc.field" ) with "cf:doc"<br> * Meanwhile, it makes sure that all fields under the same document are * initialized altogether//w w w . j a v a2s .c o m */ @Override public void prePut(final ObserverContext<RegionCoprocessorEnvironment> e, final Put put, final WALEdit edit, final boolean writeToWAL) throws IOException { HTableDescriptor desc = e.getEnvironment().getRegion().getTableDesc(); if (!DotUtil.isDot(desc)) { return; } Map<byte[], List<KeyValue>> mapper = put.getFamilyMap(); Map<byte[], Map<byte[], byte[]>> newContentMap = new HashMap(); for (Map.Entry<byte[], List<KeyValue>> mapperEntry : mapper.entrySet()) { byte[] colfamily = mapperEntry.getKey(); // each column family HColumnDescriptor coldef = desc.getFamily(colfamily); List<KeyValue> kvs = (List<KeyValue>) mapperEntry.getValue(); // docName, < field, value> Map<byte[], Map<byte[], byte[]>> fields = new TreeMap<byte[], Map<byte[], byte[]>>( Bytes.BYTES_COMPARATOR); newContentMap.put(colfamily, new TreeMap<byte[], byte[]>(Bytes.BYTES_COMPARATOR)); try { // LOG.debug("total column number: " + kvs.size()); for (KeyValue kv : kvs) { checkTimeStamp(kv); expandDocMap(fields, kv); } } catch (DotInvalidIOException ioe) { LOG.warn("Found Empty qualifier"); continue; } Map<byte[], byte[]> valueMap = newContentMap.get(colfamily); newContentMap.put(colfamily, valueMap); for (Map.Entry<byte[], Map<byte[], byte[]>> entry : fields.entrySet()) { String docName = Bytes.toString(entry.getKey()); // LOG.debug("docname: " + docName); Pair<Object, String> schemaPair = this.getSchema(coldef, docName); List<byte[]> fieldList = new ArrayList(); fieldList.addAll(entry.getValue().keySet()); byte[] docValue = getDocValue(docName, entry.getValue(), schemaPair, e.getEnvironment().getConfiguration()); valueMap.put(docName.getBytes(), docValue); } } mapper.clear(); // TODO add version information // update put data for (Map.Entry<byte[], Map<byte[], byte[]>> entry : newContentMap.entrySet()) { for (Map.Entry<byte[], byte[]> ent : entry.getValue().entrySet()) { put.add(entry.getKey(), ent.getKey(), ent.getValue()); } } }
From source file:edu.uci.ics.hyracks.api.rewriter.ActivityClusterGraphRewriter.java
/** * rewrite the blocking relationship among activity cluster * /*from w w w . ja va 2 s . c o m*/ * @param ac * the activity cluster to be rewritten */ private void rewriteInterActivityCluster(ActivityCluster ac, Map<IActivity, SuperActivity> invertedActivitySuperActivityMap) { Map<ActivityId, Set<ActivityId>> blocked2BlockerMap = ac.getBlocked2BlockerMap(); Map<ActivityId, ActivityId> invertedAid2SuperAidMap = new HashMap<ActivityId, ActivityId>(); for (Entry<IActivity, SuperActivity> entry : invertedActivitySuperActivityMap.entrySet()) { invertedAid2SuperAidMap.put(entry.getKey().getActivityId(), entry.getValue().getActivityId()); } Map<ActivityId, Set<ActivityId>> replacedBlocked2BlockerMap = new HashMap<ActivityId, Set<ActivityId>>(); for (Entry<ActivityId, Set<ActivityId>> entry : blocked2BlockerMap.entrySet()) { ActivityId blocked = entry.getKey(); ActivityId replacedBlocked = invertedAid2SuperAidMap.get(blocked); Set<ActivityId> blockers = entry.getValue(); Set<ActivityId> replacedBlockers = null; if (blockers != null) { replacedBlockers = new HashSet<ActivityId>(); for (ActivityId blocker : blockers) { replacedBlockers.add(invertedAid2SuperAidMap.get(blocker)); ActivityCluster dependingAc = ac.getActivityClusterGraph().getActivityMap() .get(invertedAid2SuperAidMap.get(blocker)); if (!ac.getDependencies().contains(dependingAc)) { ac.getDependencies().add(dependingAc); } } } if (replacedBlockers != null) { Set<ActivityId> existingBlockers = replacedBlocked2BlockerMap.get(replacedBlocked); if (existingBlockers == null) { replacedBlocked2BlockerMap.put(replacedBlocked, replacedBlockers); } else { existingBlockers.addAll(replacedBlockers); replacedBlocked2BlockerMap.put(replacedBlocked, existingBlockers); } } } blocked2BlockerMap.clear(); blocked2BlockerMap.putAll(replacedBlocked2BlockerMap); }
From source file:com.esd.ps.EmployerController.java
/** * /* www . j a v a2 s . com*/ * ?? * * @param session * @return */ @RequestMapping(value = "/unzipList", method = RequestMethod.POST) @ResponseBody public Map<String, Object> unzipList(HttpSession session) { Map<String, Object> map = new HashMap<String, Object>(); int userId = userService.getUserIdByUserName(session.getAttribute(Constants.USER_NAME).toString()); int employerId = employerService.getEmployerIdByUserId(userId); session.setAttribute(Constants.EMPLOYER_ID, employerId); String url = employerService.getUploadUrlByEmployerId(employerId); List<String> list = new ArrayList<>(); if (url != null && url.isEmpty() == false && url.trim().length() > 0) { File fold = new File(url); if (fold.exists()) { // File[] file = fold.listFiles(); for (int i = 0; i < file.length; i++) { String zipName = new String(); zipName = file[i].getName(); if (packService.getCountPackByPackName(zipName) == Constants.ZERO) { list.add(zipName); } } } } List<voiceNote> voiceNoteList = voiceNoteService.getAll("", 0, 0); List<markTimeMethod> markTimeMethodList = markTimeMethodService.getAll(); map.clear(); map.put(Constants.LIST, list); map.put("voiceNoteList", voiceNoteList); map.put("markTimeMethodList", markTimeMethodList); return map; }
From source file:io.mindmaps.graql.internal.analytics.AnalyticsTest.java
@Ignore @Test/*from w ww . j av a 2 s .c o m*/ public void testDegreeIsPersisted() throws Exception { // create a simple graph RoleType pet = graph.putRoleType("pet"); RoleType owner = graph.putRoleType("owner"); RoleType breeder = graph.putRoleType("breeder"); RelationType mansBestFriend = graph.putRelationType("mans-best-friend").hasRole(pet).hasRole(owner) .hasRole(breeder); EntityType person = graph.putEntityType("person").playsRole(owner).playsRole(breeder); EntityType animal = graph.putEntityType("animal").playsRole(pet); // make one person breeder and owner Entity coco = graph.putEntity("coco", animal); Entity dave = graph.putEntity("dave", person); Relation daveBreedsAndOwnsCoco = graph.addRelation(mansBestFriend).putRolePlayer(pet, coco) .putRolePlayer(owner, dave); // manual degrees Map<String, Long> referenceDegrees = new HashMap<>(); referenceDegrees.put(coco.getId(), 1L); referenceDegrees.put(dave.getId(), 1L); referenceDegrees.put(daveBreedsAndOwnsCoco.getId(), 2L); // validate graph.commit(); // compute and persist degrees Analytics analytics = new Analytics(keyspace); analytics.degreesAndPersist(); // check degrees are correct graph = MindmapsClient.getGraph(keyspace); referenceDegrees.entrySet().forEach(entry -> { Instance instance = graph.getInstance(entry.getKey()); if (instance.isEntity()) { assertTrue(instance.asEntity().resources().iterator().next().getValue().equals(entry.getValue())); } else if (instance.isRelation()) { assertTrue(instance.asRelation().resources().iterator().next().getValue().equals(entry.getValue())); } }); // check only expected resources exist Collection<String> allConcepts = new ArrayList<>(); ResourceType<Long> rt = graph.getResourceType(Analytics.degree); Collection<Resource<Long>> degrees = rt.instances(); Map<Instance, Long> currentDegrees = new HashMap<>(); degrees.forEach(degree -> { Long degreeValue = degree.getValue(); degree.ownerInstances().forEach(instance -> { currentDegrees.put(instance, degreeValue); }); }); // check all resources exist and no more assertTrue(CollectionUtils.isEqualCollection(currentDegrees.values(), referenceDegrees.values())); // persist again and check again analytics.degreesAndPersist(); // check only expected resources exist graph = MindmapsClient.getGraph(keyspace); rt = graph.getResourceType(Analytics.degree); degrees = rt.instances(); degrees.forEach(i -> i.ownerInstances().iterator().forEachRemaining(r -> allConcepts.add(r.getId()))); // check degrees are correct referenceDegrees.entrySet().forEach(entry -> { Instance instance = graph.getInstance(entry.getKey()); if (instance.isEntity()) { assertTrue(instance.asEntity().resources().iterator().next().getValue().equals(entry.getValue())); } else if (instance.isRelation()) { assertTrue(instance.asRelation().resources().iterator().next().getValue().equals(entry.getValue())); } }); degrees = rt.instances(); currentDegrees.clear(); degrees.forEach(degree -> { Long degreeValue = degree.getValue(); degree.ownerInstances().forEach(instance -> { currentDegrees.put(instance, degreeValue); }); }); // check all resources exist and no more assertTrue(CollectionUtils.isEqualCollection(currentDegrees.values(), referenceDegrees.values())); }
From source file:de.tu.darmstadt.lt.ner.annotator.NERAnnotator.java
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { Map<Sentence, Collection<Token>> sentencesTokens = JCasUtil.indexCovered(jCas, Sentence.class, Token.class); List<Sentence> sentences = new ArrayList<Sentence>(sentencesTokens.keySet()); // sort sentences by sentence Collections.sort(sentences, new Comparator<Sentence>() { @Override/* ww w .ja va 2 s .co m*/ public int compare(Sentence arg0, Sentence arg1) { return arg0.getBegin() - arg1.getBegin(); } }); Map<Integer, List<Instance<String>>> sentencesInstances = new LinkedHashMap<Integer, List<Instance<String>>>(); List<Sentence> sentenceList = new ArrayList<>(); int index = 0; int it = 1; for (Sentence sentence : sentences) { List<Instance<String>> instances = new ArrayList<Instance<String>>(); for (Token token : sentencesTokens.get(sentence)) { Instance<String> instance = new Instance<String>(); for (FeatureExtractor1<Token> extractor : this.featureExtractors) { if (extractor instanceof CleartkExtractor) { instance.addAll((((CleartkExtractor) extractor).extractWithin(jCas, token, sentence))); } else { instance.addAll(extractor.extract(jCas, token)); } } if (this.isTraining()) { GoldNamedEntity goldNE = JCasUtil.selectCovered(jCas, GoldNamedEntity.class, token).get(0); instance.setOutcome(goldNE.getNamedEntityType()); } // add the instance to the list !!! instances.add(instance); } // differentiate between training and classifying if (this.isTraining()) { this.dataWriter.write(instances); } // do tagging every 10,000 sentences, in favour of memory consumption else if (index > 0 && index % 10000 == 0) { File featureFile = null; if (classifierJarDir != null) { featureFile = new File(classifierJarDir, "crfsuite"); } sentencesInstances.put(index, instances); sentenceList.add(sentence); classify(jCas, sentencesTokens, sentencesInstances, sentenceList, index, it, featureFile); System.out.println(it * index + " sentences are classified"); it++; // re-initialize for next iteration sentenceList.clear(); sentencesInstances.clear(); index = 0; } else { sentencesInstances.put(index, instances); sentenceList.add(sentence); index++; } } // the last portion of the sentences if (!this.isTraining() && index > 0) { File featureFile = null; if (classifierJarDir != null) { featureFile = new File(classifierJarDir, "crfsuite"); } classify(jCas, sentencesTokens, sentencesInstances, sentenceList, index, it, featureFile); } }