List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:net.dv8tion.jda.handle.GuildMemberUpdateHandler.java
@Override protected String handleInternally(JSONObject content) { if (GuildLock.get(api).isLocked(content.getString("guild_id"))) { return content.getString("guild_id"); }// www .j a v a2 s. c o m JSONObject userJson = content.getJSONObject("user"); GuildImpl guild = (GuildImpl) api.getGuildMap().get(content.getString("guild_id")); User user = api.getUserMap().get(userJson.getString("id")); List<Role> rolesNew = toRolesList(guild, content.getJSONArray("roles")); List<Role> rolesOld = guild.getUserRoles().get(user); if (rolesOld == null) { EventCache.get(api).cache(EventCache.Type.USER, userJson.getString("id"), () -> { handle(allContent); }); EventCache.LOG.debug("Got role-update for user which is not in guild? " + content.toString()); return null; } //Find the roles removed. List<Role> removedRoles = new LinkedList<>(); for (Role role : rolesOld) { boolean roleFound = false; for (Iterator<Role> added = rolesNew.iterator(); added.hasNext();) { Role r = added.next(); if (role.equals(r)) { added.remove(); roleFound = true; break; } } if (!roleFound) removedRoles.add(role); } if (removedRoles.size() > 0) { rolesOld.removeAll(removedRoles); } if (rolesNew.size() > 0) { rolesOld.addAll(rolesNew); } Collections.sort(rolesOld, (r1, r2) -> r2.compareTo(r1)); if (removedRoles.size() > 0) { api.getEventManager() .handle(new GuildMemberRoleRemoveEvent(api, responseNumber, guild, user, removedRoles)); } if (rolesNew.size() > 0) { api.getEventManager().handle(new GuildMemberRoleAddEvent(api, responseNumber, guild, user, rolesNew)); } if (content.has("nick")) { Map<User, String> nickMap = guild.getNickMap(); String prevNick = nickMap.get(user); if (content.isNull("nick")) { if (prevNick != null) { nickMap.remove(user); api.getEventManager().handle( new GuildMemberNickChangeEvent(api, responseNumber, guild, user, prevNick, null)); } } else if (!content.getString("nick").equals(prevNick)) { nickMap.put(user, content.getString("nick")); api.getEventManager().handle(new GuildMemberNickChangeEvent(api, responseNumber, guild, user, prevNick, content.getString("nick"))); } } return null; }
From source file:com.foya.noms.service.st.ST004Service.java
/** * siteBuildApply/*from w w w . j ava2 s . c o m*/ * * @param siteBuildApply * @return */ @Transactional public void update(SiteBuildApplyDTO siteBuildApply, String[] orderIdArray, String mdUser, String siteStatus) throws UpdateFailException, Exception { Date mdTime = new Date(); TownDomainTeamDTO domainTeam = null; boolean hasChangeDomain = false; String workId = siteBuildApply.getWorkId(); TbSiteWork siteWorkTarget = workDao.findByPk(workId); // ?????? add by Charlie 20150415 if (!StringUtils.equals(siteBuildApply.getAREA(), siteWorkTarget.getAREA())) { hasChangeDomain = true; domainTeam = townDomainTeamDao.getTownDomainTeamByCityIdTownId(siteBuildApply.getCITY(), siteBuildApply.getAREA()); } // TbSiteWork siteWork = this.getSiteWorkBySiteBuildApplyDTO(siteBuildApply, workId); siteWork.setMD_USER(mdUser); siteWork.setMD_TIME(mdTime); String[] ignoreProperties = { "WORK_TYPE", "CR_USER", "CR_TIME", "APP_DEPT", "APL_USER", "APL_TIME", "END_TIME", "SR_ID", "SR_COVER_RANG", "END_DATE", "CPL_NO", "PERMIT_NO", "LICENSE_NO" }; BeanUtils.copyProperties(siteWork, siteWorkTarget, ignoreProperties); int siteWorkItem = workDao.update(siteWorkTarget); if (siteWorkItem == 0) { log.error("siteWorkItem update count= " + siteWorkItem + " , workId = " + siteWork.getWORK_ID()); throw new UpdateFailException(""); } // if (orderIdArray != null) { TbSiteWorkOrderExample example = new TbSiteWorkOrderExample(); example.createCriteria().andWORK_IDEqualTo(workId); List<TbSiteWorkOrder> workOrderList = workOrderDao.findByConditions(example); List<String> orderIdList_source = new ArrayList<String>(); for (TbSiteWorkOrder workOrder : workOrderList) { orderIdList_source.add(workOrder.getORDER_ID()); if (hasChangeDomain) { // ?DOMAIN??? add by Charlie 20150415 String deptKey = orderTypeService.getOrdersDeptKey(workOrder.getORDER_TYPE(), domainTeam.getDOMAIN(), siteWorkTarget.getEQP_TYPE_ID()); TbOrgDept newNept = orderTypeService.getOrderTypeForWorkArea(deptKey, domainTeam); workOrder.setREP_DEPT(newNept.getDEPT_ID()); workOrderDao.updateSelective(workOrder); } } List<String> orderIdList_target = new ArrayList<String>(); //???isActive=Y for (String orderId : orderIdArray) { TbSiteWorkOrder siteWorkOrder = workOrderDao.findOrderByPk(orderId); siteWorkOrder.setIS_ACTIVE("Y"); siteWorkOrder.setORDER_ID(orderId); siteWorkOrder.setPRIORITY(siteBuildApply.getPriority()); siteWorkOrder.setMD_USER(mdUser); siteWorkOrder.setMD_TIME(mdTime); int workOrderItem = workOrderDao.updateSelective(siteWorkOrder); if (workOrderItem == 0) { log.error("workOrderItem update count= " + workOrderItem + " , orderId = " + siteWorkOrder.getORDER_ID()); throw new UpdateFailException(""); } orderIdList_target.add(orderId); } //DB??isActive=N List<String> orderIdList_isNotActive = new ArrayList<String>(orderIdList_source); orderIdList_isNotActive.removeAll(orderIdList_target); //???isActive=N if (orderIdList_isNotActive.size() > 0) { for (String orderId : orderIdList_isNotActive) { TbSiteWorkOrder siteWorkOrder = workOrderDao.findOrderByPk(orderId); siteWorkOrder.setIS_ACTIVE("N"); siteWorkOrder.setORDER_ID(orderId); siteWorkOrder.setPRIORITY(siteBuildApply.getPriority()); siteWorkOrder.setMD_USER(mdUser); siteWorkOrder.setMD_TIME(mdTime); int workOrderItem = workOrderDao.updateSelective(siteWorkOrder); if (workOrderItem == 0) { log.error("workOrderItem update count= " + workOrderItem + " , orderId = " + siteWorkOrder.getORDER_ID()); throw new UpdateFailException(""); } } } } // ? TbSiteMain siteMain = this.getSiteMainBySiteWork(siteWork, mdTime, siteStatus); int mainItem = 0; siteMain.setMD_USER(mdUser); siteMain.setMD_TIME(mdTime); mainItem = siteMainDao.update(siteMain); if (mainItem == 0) { log.error("mainItem update count= " + mainItem + " , siteId = " + siteMain.getSITE_ID()); throw new UpdateFailException(""); } }
From source file:com.google.ie.business.service.impl.TagServiceImpl.java
@Override public List<Tag> removeTagWithZeroWeight(List<Tag> tagList) { Collection<Tag> tagsToBeRemoved = new ArrayList<Tag>(); Iterator<Tag> iterator = tagList.iterator(); Tag tag;//from w w w . jav a 2 s. com /* Iterate the list and remove the tags with zero weight */ while (iterator.hasNext()) { tag = iterator.next(); if (tag.getWeightage() <= ServiceConstants.ZERO) { tagsToBeRemoved.add(tag); } } if (tagsToBeRemoved.size() > ServiceConstants.ZERO) { log.debug("Removing " + tagsToBeRemoved.size() + " tags from the fetched list because they have ZERO weight"); tagList.removeAll(tagsToBeRemoved); } return tagList; }
From source file:com.projity.pm.graphic.model.event.CompositeCacheEvent.java
private void generateDiffLists() { if (diffListsGenerated) return;/*w w w .j av a 2 s . c o m*/ //nodes CacheEvent event; List nodes; for (Iterator i = nodeEvents.iterator(); i.hasNext();) { event = (CacheEvent) i.next(); nodes = event.getNodes(); switch (event.getType()) { case CacheEvent.NODES_CHANGED: if (nodes != null && nodes.size() > 0) { if (updatedNodes == null) updatedNodes = new ArrayList(nodes.size()); updatedNodes.addAll(nodes); } break; case CacheEvent.NODES_INSERTED: // check for hidden updates if (removedNodes != null) { List inter = ListUtils.intersection(nodes, removedNodes); if (inter.size() > 0) { removedNodes.removeAll(inter); nodes.removeAll(inter); if (updatedNodes == null) updatedNodes = new ArrayList(nodes.size()); updatedNodes.addAll(inter); } } if (nodes != null && nodes.size() > 0) { if (insertedNodes == null) insertedNodes = new ArrayList(nodes.size()); insertedNodes.addAll(nodes); } break; case CacheEvent.NODES_REMOVED: //INSERT FOLLOWED BY REMOVE NEVER HAPPENS //nothing special to handle if (nodes != null && nodes.size() > 0) { if (removedNodes == null) removedNodes = new ArrayList(nodes.size()); removedNodes.addAll(nodes); } break; default: break; } } //edges for (Iterator i = edgeEvents.iterator(); i.hasNext();) { event = (CacheEvent) i.next(); nodes = event.getNodes(); switch (event.getType()) { case CacheEvent.NODES_CHANGED: if (nodes != null && nodes.size() > 0) { if (updatedEdges == null) updatedEdges = new ArrayList(nodes.size()); updatedEdges.addAll(nodes); } break; case CacheEvent.NODES_INSERTED: if (nodes != null && nodes.size() > 0) { if (insertedEdges == null) insertedEdges = new ArrayList(nodes.size()); insertedEdges.addAll(nodes); } break; case CacheEvent.NODES_REMOVED: if (nodes != null && nodes.size() > 0) { if (removedEdges == null) removedEdges = new ArrayList(nodes.size()); removedEdges.addAll(nodes); } break; default: break; } } diffListsGenerated = true; }
From source file:services.echannel.EchannelServiceImpl.java
@Override public DataSyndicationAgreement submitAgreement(String refId, String name, Date startDate, Date endDate, List<Long> agreementItemIds, String slaveDomain) throws EchannelException { SubmitDataSyndicationAgreementRequest submitAgreementRequest = new SubmitDataSyndicationAgreementRequest(); submitAgreementRequest.refId = refId; submitAgreementRequest.name = name;/*from w w w .java 2s.c o m*/ submitAgreementRequest.startDate = startDate; submitAgreementRequest.endDate = endDate; agreementItemIds.removeAll(Collections.singleton(null)); submitAgreementRequest.agreementItemIds = agreementItemIds; submitAgreementRequest.slaveDomain = slaveDomain; JsonNode content = getMapper().valueToTree(submitAgreementRequest); JsonNode response = this.call(HttpMethod.POST, DATA_SYNDICATION_AGREEMENT_ACTION + "/submit", null, content); return getMapper().convertValue(response, DataSyndicationAgreement.class); }
From source file:com.inkubator.hrm.web.recruitment.OfferingAndProhabitFormController.java
@PostConstruct @Override/* w ww. j av a 2 s .c o m*/ public void initialization() { try { super.initialization(); List<RecruitSelectionType> sourceDualLis = recruitSelectionTypeService.getAllData(); List<RecruitCommChannels> sourceDualLisCom = recruitCommChannelsService.getAllData(); String offeringLetterId = FacesUtil.getRequestParameter("execution"); if (offeringLetterId != null) { isEdit = Boolean.TRUE; RecruitLetters recruitLetters = recruitLettersService .getByPkWithDetail(Long.parseLong(offeringLetterId.substring(1))); offeringAndProhabitModel = getModelFromEntity(recruitLetters); List<RecruitSelectionType> targetSelectionType = recruitLetters.getRecruitSelectionTypes(); List<RecruitCommChannels> recruitCommChannelss = recruitLetters.getRecruitCommChannelss(); sourceDualLis.removeAll(targetSelectionType); sourceDualLisCom.removeAll(recruitCommChannelss); dualListModel = new DualListModel<>(sourceDualLis, targetSelectionType); dualListModelCom = new DualListModel<>(sourceDualLisCom, recruitCommChannelss); } else { isEdit = Boolean.FALSE; offeringAndProhabitModel = new OfferingAndProhabitModel(); offeringAndProhabitModel.setExpiryDays(1); dualListModel.setSource(sourceDualLis); dualListModelCom.setSource(sourceDualLisCom); } warningMessage = ""; } catch (Exception ex) { LOGGER.error(ex, ex); } }
From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.common.action.BiospecimenMetaDataProcessor.java
/** * Extracts biospecimen meta-data from a clinical XML file and returns a list of {@link BiospecimenMetaData} * objects. Each object represents a single XML meta-data element. * * @param xmlFile - the XML file to extract biospecimen meta-data from * @param qcContext - qcContext// w w w . j a va 2s . c o m * @return a list of {@link BiospecimenMetaData} objects, with each object representing a single meta-data element * @throws UUIDException if an error occurs while attempting to generate a UUID for a specific meta-data * element when not provided in the XML * @throws ProcessorException if errors occur while attempting extract meta-data */ protected List<BiospecimenMetaData> handleBiospecimenMetaData(final File xmlFile, final QcContext qcContext) throws UUIDException, ProcessorException { logger.debug("starting handleBiospecimenMetadata"); final Archive archive = qcContext.getArchive(); // Unmarshal the XML file into a JAXB generated object TcgaBcr tcgaBcr; UnmarshalResult unmarshalResult; JAXBIntrospector jaxbIntrospector; try { unmarshalResult = JAXBUtil.unmarshal(xmlFile, TcgaBcr.class, true, false); tcgaBcr = (TcgaBcr) unmarshalResult.getJaxbObject(); jaxbIntrospector = JAXBUtil.getJAXBIntrospector(TcgaBcr.class); logger.debug("JAXB Unmarshalling of BiospecimenMetadata done"); } catch (Exception e) { logger.info(e); throw new ProcessorException(e.getMessage()); } Map<String, BiospecimenMetaData> biospecimenMetaDataByUUIDORBarcode; List<BiospecimenMetaData> biospecimenMetaData = null; if (tcgaBcr != null) { final Patient patient = tcgaBcr.getPatient(); if (patient != null) { biospecimenMetaDataByUUIDORBarcode = new LinkedHashMap<String, BiospecimenMetaData>(); final BiospecimenMetaData patientMetaData = new BiospecimenMetaData(); final String uuid = JAXBUtil.getJAXBObjectValue(patient.getBcrPatientUuid()); patientMetaData.setBarcode(patient.getBcrPatientBarcode().getValue()); setUUID(patientMetaData, uuid, archive); patientMetaData.setUuidType(jaxbIntrospector.getElementName(patient).getLocalPart()); patientMetaData.setBcr(archive.getTheCenter().getCenterId().toString()); patientMetaData.setBatch(archive.getSerialIndex()); patientMetaData.setDisease(archive.getTheTumor().getTumorName()); patientMetaData.setParticipantId(patient.getPatientId().getValue()); patientMetaData.setTissueSourceSite(patient.getTissueSourceSite().getValue()); biospecimenMetaDataByUUIDORBarcode.put( (uuid == null || uuid.isEmpty()) ? patientMetaData.getBarcode() : patientMetaData.getUuid(), patientMetaData); logger.debug("Patient metadata done"); // Get the transform of JAXB object into a list of meta-data entity objects getSampleMetaData(patient, patientMetaData, biospecimenMetaDataByUUIDORBarcode, jaxbIntrospector, archive); logger.debug("Sample metadata done"); getDrugMetaData(patient, patientMetaData, biospecimenMetaDataByUUIDORBarcode, jaxbIntrospector, archive); logger.debug("Drug metadata done"); getRadiationMetaData(patient, patientMetaData, biospecimenMetaDataByUUIDORBarcode, jaxbIntrospector, archive); logger.debug("Radiation metadata done"); getExaminationMetaData(patient, patientMetaData, biospecimenMetaDataByUUIDORBarcode, jaxbIntrospector, archive); logger.debug("Examination metadata done"); getSurgeryMetaData(patient, patientMetaData, biospecimenMetaDataByUUIDORBarcode, jaxbIntrospector, archive); logger.debug("Surgery metadata done"); biospecimenMetaData = new ArrayList<BiospecimenMetaData>( biospecimenMetaDataByUUIDORBarcode.values()); // Persist the meta-data if (!biospecimenMetaDataByUUIDORBarcode.isEmpty()) { // Get the existing meta data from the data base and warn the user if the meta data is changed. final Map<String, BiospecimenMetaData> existingBiospecimenMetaData = uuidHierarchyQueries .getMetaData(new ArrayList<String>(biospecimenMetaDataByUUIDORBarcode.keySet())); logger.debug("Get existing metadata: " + existingBiospecimenMetaData); logger.debug("Persisting metadata starting"); uuidHierarchyQueries.persistUUIDHierarchy(biospecimenMetaData); logger.debug("Persisting metadata done"); final List<BiospecimenMetaData> updatedMetaData = new ArrayList<BiospecimenMetaData>(); // get the updatedMetadata for (final String existingUUIDOrBarcode : existingBiospecimenMetaData.keySet()) { updatedMetaData.add(biospecimenMetaDataByUUIDORBarcode.get(existingUUIDOrBarcode)); } // remove the metadata that are not changed updatedMetaData.removeAll(existingBiospecimenMetaData.values()); if (updatedMetaData.size() > 0) { final StringBuffer warning = new StringBuffer(); for (final BiospecimenMetaData metaData : updatedMetaData) { warning.append("Meta data was updated: "); // get the existing meta data. Key can be either uuid or barcode BiospecimenMetaData existingMetaData = existingBiospecimenMetaData .get(metaData.getUuid()); existingMetaData = (existingMetaData == null) ? existingBiospecimenMetaData.get(metaData.getBarcode()) : existingMetaData; warning.append(existingMetaData.getMetaDataString()).append("-->") .append(metaData.getMetaDataString()); qcContext.addWarning(warning.toString()); warning.delete(0, warning.length()); } } } } processControls(tcgaBcr); } return biospecimenMetaData; }
From source file:com.zht.common.rabc.service.impl.RbacRoleServiceImpl.java
@SuppressWarnings("unchecked") @Override/* ww w . ja va2 s.co m*/ public List<String> findRoleCodeUserHave(Long userId, Boolean isEnable) { //A: userRole(+) List<String> fromUserRole = findRoleCodeInUserRoleByUserId(userId, isEnable); //B: userRole(-) List<String> fromUserRoleReject = findRoleCodeInUserRoleRejectByUserId(userId, isEnable); //C: user extends group (+) List<String> fromUserEGroups = findRoleCodeFromUserExtendsGroupsByUserId(userId, isEnable); //D: user extends Department (+) List<String> fromUserEDepartment = findRoleCodeFromUserExtendsDepartmentsByUserId(userId, isEnable); List<String> finalList = new ArrayList<String>(); if (fromUserRole != null) { finalList.addAll(fromUserRole); } if (fromUserEGroups != null) { finalList.addAll(fromUserEGroups); } if (fromUserEDepartment != null) { finalList.addAll(fromUserEDepartment); } finalList = (List<String>) ZBeanUtil.removeDuplicateWithOrder(finalList); if (fromUserRoleReject != null) { finalList.removeAll(fromUserRoleReject); } return finalList; }
From source file:au.org.theark.lims.web.component.biospecimenuidtemplate.form.DetailForm.java
/** * Returns a list of Studies the user is permitted to access * /* w w w .ja va 2 s . c om*/ * @return */ private List<Study> getStudyListForUser() { List<Study> studyListForUser = new ArrayList<Study>(0); try { Subject currentUser = SecurityUtils.getSubject(); ArkUser arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString()); ArkUserVO arkUserVo = new ArkUserVO(); arkUserVo.setArkUserEntity(arkUser); Long sessionArkModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); ArkModule arkModule = null; arkModule = iArkCommonService.getArkModuleById(sessionArkModuleId); studyListForUser = iArkCommonService.getStudyListForUserAndModule(arkUserVo, arkModule); // Remove possible Study's already assigned a BiospecimenUidTemplate if (isNew()) { studyListForUser.removeAll(iLimsAdminService.getStudyListAssignedToBiospecimenUidTemplate()); } } catch (EntityNotFoundException e) { log.error(e.getMessage()); } return studyListForUser; }
From source file:de.bund.bfr.knime.pmm.common.chart.Plotable.java
public Map<String, List<Double>> getPossibleArgumentValues(boolean useData, boolean useMinMax) { Map<String, List<Double>> args = new LinkedHashMap<>(); for (String var : functionArguments.keySet()) { Double min = minArguments.get(var); Double max = maxArguments.get(var); if (useData && valueLists.get(var) != null) { Set<Double> valuesSet = new LinkedHashSet<>(valueLists.get(var)); List<Double> valuesList = new ArrayList<>(valuesSet); valuesList.removeAll(Arrays.asList((Object) null)); Collections.sort(valuesList); args.put(var, valuesList); } else if (useMinMax && min != null) { args.put(var, new ArrayList<>(Arrays.asList(min))); } else if (useMinMax && max != null) { args.put(var, new ArrayList<>(Arrays.asList(max))); } else {/* w w w . java 2 s . co m*/ args.put(var, new ArrayList<Double>()); } } return args; }