List of usage examples for java.util Set remove
boolean remove(Object o);
From source file:com.modelmetrics.cloudconverter.engine.ObjectDeleteHandler.java
public List<CloudConverterObject> determineOrder(List<CloudConverterObject> originalList) throws Exception { // status/* w w w . ja v a 2 s. c om*/ this.statusSubscriber.publish("Determining Object Delete Order"); // build a map of fields to describe sobject results Map<String, ObjectDeleteBean> sobjects = new HashMap<String, ObjectDeleteBean>(); for (CloudConverterObject current : originalList) { if (current.isExistsInSalesforce()) { ObjectDeleteBean objectDeleteBean = new ObjectDeleteBean(); objectDeleteBean.setOriginal(current); objectDeleteBean.setDescribeSObjectResult( this.salesforceSession.getSalesforceService().describeSObject(current.getObjectName())); sobjects.put(current.getObjectName(), objectDeleteBean); } } // determine order -- in the case where there is a many to one // relationship, // we must delete the many side of the relationship before we delete the // one. for (String objectName : sobjects.keySet()) { log.info("inspecting: " + objectName); ObjectDeleteBean current = sobjects.get(objectName); Set<String> otherObjects = new TreeSet<String>(); otherObjects.addAll(sobjects.keySet()); otherObjects.remove(objectName); for (Field field : current.getDescribeSObjectResult().getFields()) { if (field.getType().getValue().equalsIgnoreCase("reference")) { if (field.getReferenceTo().length == 1) { if (otherObjects.contains(field.getReferenceTo(0))) { current.getOtherObjectRef().add(field.getReferenceTo(0)); log.info("reference to.." + field.getReferenceTo(0)); current.setRefToOtherObjectCount(current.getRefToOtherObjectCount() + 1); } } } } } //sort them by reference count, highest first then return Set<ObjectDeleteBean> sortedSet = new TreeSet<ObjectDeleteBean>(new ObjectDeleteBeanComparator()); sortedSet.addAll(sobjects.values()); List<CloudConverterObject> ret = new ArrayList<CloudConverterObject>(); for (ObjectDeleteBean current : sortedSet) { ret.add(current.getOriginal()); log.info(current.getOriginal().getObjectName()); } return ret; }
From source file:org.magnum.mobilecloud.video.VideoSvc.java
@RequestMapping(value = VideoSvcApi.VIDEO_SVC_PATH + "/{id}/unlike", method = RequestMethod.POST) public @ResponseBody void unlikeVideo(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response) {// ww w.j a v a 2s . c o m Video video = videos.findOne(id); if (video != null) { Set<String> users = video.getLikesUserNames(); String user = request.getRemoteUser(); if (users.contains(user)) { users.remove(user); video.setLikesUserNames(users); video.setLikes(users.size()); videos.save(video); response.setStatus(HttpServletResponse.SC_OK); } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } } else { response.setStatus(HttpServletResponse.SC_NOT_FOUND); } }
From source file:de.hybris.platform.b2bacceleratorfacades.order.populators.B2BCustomerReversePopulator.java
@Override public void populate(final CustomerData source, final B2BCustomerModel target) throws ConversionException { target.setEmail(source.getEmail());//from w w w . j ava 2 s . c o m target.setName(getCustomerNameStrategy().getName(source.getFirstName(), source.getLastName())); final B2BUnitModel defaultUnit = getCompanyB2BCommerceService().getUnitForUid(source.getUnit().getUid()); final B2BUnitModel oldDefaultUnit = getB2bUnitService().getParent(target); target.setDefaultB2BUnit(defaultUnit); final Set<PrincipalGroupModel> groups = new HashSet<PrincipalGroupModel>(target.getGroups()); if (oldDefaultUnit != null && groups.contains(oldDefaultUnit)) { groups.remove(oldDefaultUnit); } groups.add(defaultUnit); target.setGroups(groups); getB2BCommerceB2BUserGroupService().updateUserGroups(getUserGroups(), source.getRoles(), target); if (StringUtils.isNotBlank(source.getTitleCode())) { target.setTitle(getUserService().getTitleForCode(source.getTitleCode())); } else { target.setTitle(null); } setUid(source, target); }
From source file:com.smhdemo.common.report.service.TextService.java
@Override public void delText(Long pk) { Text text = textDao.get(pk);/*from www . ja v a2 s.c o m*/ Assert.notNull(text); List<Category> categories = textDao.findCategoryReportByTextReportId(pk); if (categories != null && !categories.isEmpty()) { for (Category category : categories) { Set<Text> texts = category.getTextReports(); if (texts.isEmpty()) continue; texts.remove(text); category.setTextReports(texts); categorDao.merge(category); } } // List<EwcmsJobReport> ewcmsJobReports = textDao.findEwcmsJobReportByTextReportId(textReportId); // if (ewcmsJobReports != null && !ewcmsJobReports.isEmpty()){ // for (EwcmsJobReport ewcmsJobReport : ewcmsJobReports){ // if (ewcmsJobReport.getChartReport() == null){ // ewcmsJobReportDAO.remove(ewcmsJobReport); // }else{ // ewcmsJobReport.setTextReport(null); // ewcmsJobReportDAO.merge(ewcmsJobReport); // } // } // } textDao.removeByPK(pk); }
From source file:logic.LogicaTorneo.java
public void deleteJugador(int torneo, int jugador) { Torneo t = torneoRepository.findOne(torneo); Set<Jugador> s = t.getJugadoreses(); Jugador oldj = null;//w w w . j a v a 2 s .co m for (Jugador j : s) { if (j.getCodigofide() == jugador) { oldj = j; } } s.remove(oldj); t.setJugadoreses(s); torneoRepository.save(t); }
From source file:com.espertech.esper.filter.FilterParamIndexNotIn.java
public final boolean remove(Object filterConstant) { MultiKeyUntyped keys = (MultiKeyUntyped) filterConstant; // remove the mapping of value set to evaluator EventEvaluator eval = filterValueEvaluators.remove(keys); evaluatorsSet.remove(eval);/*from w w w . j a va 2 s. com*/ boolean isRemoved = false; if (eval != null) { isRemoved = true; } Object[] keyValues = keys.getKeys(); for (Object keyValue : keyValues) { Set<EventEvaluator> evaluators = constantsMap.get(keyValue); if (evaluators != null) // could already be removed as constants may be the same { evaluators.remove(eval); if (evaluators.isEmpty()) { constantsMap.remove(keyValue); } } } return isRemoved; }
From source file:org.ow2.proactive.procci.service.occi.MixinService.java
/** * Remove a mixin from the database and update the references * @param mixinTitle the title of the mixin to remove *///from w w w . j a v a2s. c om public void removeMixin(String mixinTitle) { Mixin mixinToRemove = getMixinByTitle(mixinTitle); List<Entity> entities = mixinToRemove.getEntities(); cloudAutomationVariablesClient.delete(mixinTitle); entities.forEach(entity -> { getMixinNamesFromEntity(entity.getId()).remove(mixinTitle); }); entities.forEach(entity -> { Set<String> entityMixins = getMixinNamesFromEntity(entity.getId()); entityMixins.remove(mixinTitle); cloudAutomationVariablesClient.update(entity.getId(), mapObject(entityMixins)); }); }
From source file:de.hybris.platform.b2bacceleratorservices.company.impl.DefaultB2BCommerceUserService.java
@Override public B2BCustomerModel removeUserRole(final String user, final String role) { final B2BCustomerModel customerModel = getCustomerForUid(user); validateParameterNotNullStandardMessage("usser", user); final UserGroupModel userGroupModel = this.getUserService().getUserGroupForUID(role); validateParameterNotNullStandardMessage("user group", role); final Set<PrincipalGroupModel> customerModelGroups = new HashSet<PrincipalGroupModel>( customerModel.getGroups());//from w w w .j a v a 2 s . com customerModelGroups.remove(userGroupModel); customerModel.setGroups(customerModelGroups); this.getModelService().save(customerModel); return customerModel; }
From source file:ddf.catalog.metacard.validation.MetacardValidityMarkerPlugin.java
private <T> T validate(T item, Function<T, Metacard> itemToMetacard, Map<String, Integer> counter) { Set<Serializable> newErrors = new HashSet<>(); Set<Serializable> newWarnings = new HashSet<>(); Set<Serializable> errorValidators = new HashSet<>(); Set<Serializable> warningValidators = new HashSet<>(); Metacard metacard = itemToMetacard.apply(item); Set<String> tags = metacard.getTags(); tags.remove(VALID_TAG); tags.remove(INVALID_TAG);//from ww w. ja v a 2 s . c om String valid = VALID_TAG; for (MetacardValidator validator : metacardValidators) { try { validator.validate(metacard); } catch (ValidationException e) { String validatorName = getValidatorName(validator); boolean validationErrorsExist = CollectionUtils.isNotEmpty(e.getErrors()); boolean validationWarningsExist = CollectionUtils.isNotEmpty(e.getWarnings()); if ((isValidatorEnforced(validatorName) && validationErrorsExist && enforceErrors) || isValidatorEnforced(validatorName) && validationWarningsExist && enforceWarnings) { INGEST_LOGGER.debug( "The metacard with id={} is being removed from the operation because it failed the enforced validator [{}].", metacard.getId(), validatorName); return null; } else { getValidationProblems(validatorName, e, newErrors, newWarnings, errorValidators, warningValidators, counter); } } } Attribute existingErrors = metacard.getAttribute(Validation.VALIDATION_ERRORS); Attribute existingWarnings = metacard.getAttribute(Validation.VALIDATION_WARNINGS); if (existingErrors != null) { newErrors.addAll(existingErrors.getValues()); } if (existingWarnings != null) { newWarnings.addAll(existingWarnings.getValues()); } if (!newErrors.isEmpty() || !newWarnings.isEmpty()) { valid = INVALID_TAG; } tags.add(valid); metacard.setAttribute(new AttributeImpl(Metacard.TAGS, new ArrayList<String>(tags))); metacard.setAttribute( new AttributeImpl(Validation.VALIDATION_ERRORS, (List<Serializable>) new ArrayList<>(newErrors))); metacard.setAttribute(new AttributeImpl(Validation.VALIDATION_WARNINGS, (List<Serializable>) new ArrayList<>(newWarnings))); metacard.setAttribute(new AttributeImpl(Validation.FAILED_VALIDATORS_WARNINGS, (List<Serializable>) new ArrayList<>(warningValidators))); metacard.setAttribute(new AttributeImpl(Validation.FAILED_VALIDATORS_ERRORS, (List<Serializable>) new ArrayList<>(errorValidators))); return item; }