List of usage examples for org.apache.commons.collections4 MultiValuedMap keySet
Set<K> keySet();
From source file:com.evolveum.midpoint.task.quartzimpl.work.workers.WorkersManager.java
/** * Going through the groups and renaming wrongly-named tasks to the correct names. *//* ww w . j av a 2 s . co m*/ private int renameWorkers(List<Task> currentWorkers, MultiValuedMap<String, WorkerKey> shouldBeWorkers, OperationResult result) throws SchemaException, ObjectNotFoundException, ObjectAlreadyExistsException { int count = 0; for (String shouldBeGroup : shouldBeWorkers.keySet()) { Collection<WorkerKey> shouldBeWorkersInGroup = shouldBeWorkers.get(shouldBeGroup); for (Task currentWorker : new ArrayList<>(currentWorkers)) { if (Objects.equals(shouldBeGroup, currentWorker.getGroup())) { if (!shouldBeWorkersInGroup.isEmpty()) { WorkerKey nextWorker = shouldBeWorkersInGroup.iterator().next(); renameWorker(currentWorker, nextWorker.name, result); currentWorkers.remove(currentWorker); shouldBeWorkersInGroup.remove(nextWorker); count++; } else { break; // no more workers for this group } } } } LOGGER.trace("After renameWorkers (result: {}):\nCurrent workers: {}\nShould be workers: {}", count, currentWorkers, shouldBeWorkers); return count; }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistryImpl.java
private void parsePrismSchemas(List<SchemaDescription> schemaDescriptions, boolean allowDelayedItemDefinitions) throws SchemaException { List<SchemaDescription> prismSchemaDescriptions = schemaDescriptions.stream() .filter(sd -> sd.isPrismSchema()).collect(Collectors.toList()); Element schemaElement = DOMUtil.createElement(DOMUtil.XSD_SCHEMA_ELEMENT); schemaElement.setAttribute("targetNamespace", "http://dummy/"); schemaElement.setAttribute("elementFormDefault", "qualified"); // These fragmented namespaces should not be included in wrapper XSD because they are defined in multiple XSD files. // We have to process them one by one. MultiValuedMap<String, SchemaDescription> schemasByNamespace = new ArrayListValuedHashMap<>(); prismSchemaDescriptions.forEach(sd -> schemasByNamespace.put(sd.getNamespace(), sd)); List<String> fragmentedNamespaces = schemasByNamespace.keySet().stream() .filter(ns -> schemasByNamespace.get(ns).size() > 1).collect(Collectors.toList()); LOGGER.trace("Fragmented namespaces: {}", fragmentedNamespaces); List<SchemaDescription> wrappedDescriptions = new ArrayList<>(); for (SchemaDescription description : prismSchemaDescriptions) { String namespace = description.getNamespace(); if (!fragmentedNamespaces.contains(namespace)) { Element importElement = DOMUtil.createSubElement(schemaElement, DOMUtil.XSD_IMPORT_ELEMENT); importElement.setAttribute(DOMUtil.XSD_ATTR_NAMESPACE.getLocalPart(), namespace); description.setSchema(new PrismSchemaImpl(prismContext)); wrappedDescriptions.add(description); }//from w w w . j a v a 2 s. com } if (LOGGER.isTraceEnabled()) { String xml = DOMUtil.serializeDOMToString(schemaElement); LOGGER.trace("Wrapper XSD:\n{}", xml); } long started = System.currentTimeMillis(); LOGGER.trace("Parsing {} schemas wrapped in single XSD", wrappedDescriptions.size()); PrismSchemaImpl.parseSchemas(schemaElement, entityResolver, wrappedDescriptions, allowDelayedItemDefinitions, getPrismContext()); LOGGER.trace("Parsed {} schemas in {} ms", wrappedDescriptions.size(), System.currentTimeMillis() - started); for (SchemaDescription description : wrappedDescriptions) { detectExtensionSchema(description.getSchema()); } for (String namespace : fragmentedNamespaces) { Collection<SchemaDescription> fragments = schemasByNamespace.get(namespace); LOGGER.trace("Parsing {} schemas for fragmented namespace {}", fragments.size(), namespace); for (SchemaDescription schemaDescription : fragments) { parsePrismSchema(schemaDescription, allowDelayedItemDefinitions); } } }
From source file:org.openecomp.sdc.vendorlicense.licenseartifacts.impl.VendorLicenseArtifactsServiceImpl.java
private static List<VersionableEntity> filterChangedEntities( Collection<? extends VersionableEntity> versionableEntities) { MultiValuedMap<String, VersionableEntity> entitiesById = mapById(versionableEntities); Map<String, VersionableEntity> entitiesByVersionUuId = new HashMap<>(); List<VersionableEntity> changedOnly = new ArrayList<>(); for (String epId : entitiesById.keySet()) { Collection<VersionableEntity> versionableEntitiesForId = entitiesById.get(epId); for (VersionableEntity ep : versionableEntitiesForId) { entitiesByVersionUuId.put(ep.getVersionUuId(), ep); }//from w ww . ja v a2 s .c o m } changedOnly.addAll(entitiesByVersionUuId.values()); return changedOnly; }