@Override public ConceptMaps withConceptMaps(Dataset<ConceptMap> conceptMaps) { Dataset<UrlAndVersion> newMembers = getUrlAndVersions(conceptMaps); if (hasDuplicateUrlAndVersions(newMembers) || conceptMaps.count() != newMembers.count()) { throw new IllegalArgumentException( "Cannot add concept maps having duplicate conceptMapUri and conceptMapVersion"); } // Remove the concept contents for persistence. This is most easily done in the ConceptMap // object by setting the group to an empty list. Dataset<ConceptMap> withoutConcepts = conceptMaps .map((MapFunction<ConceptMap,ConceptMap>) conceptMap -> { // Remove the elements rather than the groups to preserved the // "unmapped" structure in a group that can refer to other // concept maps. ConceptMap withoutElements = conceptMap.copy(); List<ConceptMapGroupComponent> updatedGroups = new ArrayList<>(); for (ConceptMapGroupComponent group: withoutElements.getGroup()) { group.setElement(new ArrayList<>()); updatedGroups.add(group); } withoutElements.setGroup(updatedGroups); return withoutElements; }, CONCEPT_MAP_ENCODER); Dataset<Mapping> newMappings = conceptMaps.flatMap(ConceptMaps::expandMappingsIterator, MAPPING_ENCODER); return withConceptMaps(withoutConcepts, newMappings); }
@Override public ConceptMaps withConceptMaps(Dataset<ConceptMap> conceptMaps) { Dataset<UrlAndVersion> newMembers = getUrlAndVersions(conceptMaps); if (hasDuplicateUrlAndVersions(newMembers) || conceptMaps.count() != newMembers.count()) { throw new IllegalArgumentException( "Cannot add concept maps having duplicate conceptMapUri and conceptMapVersion"); } // Remove the concept contents for persistence. This is most easily done in the ConceptMap // object by setting the group to an empty list. Dataset<ConceptMap> withoutConcepts = conceptMaps .map((MapFunction<ConceptMap,ConceptMap>) conceptMap -> { // Remove the elements rather than the groups to preserved the // "unmapped" structure in a group that can refer to other // concept maps. ConceptMap withoutElements = conceptMap.copy(); List<ConceptMapGroupComponent> updatedGroups = new ArrayList<>(); for (ConceptMapGroupComponent group: withoutElements.getGroup()) { group.setElement(new ArrayList<>()); updatedGroups.add(group); } withoutElements.setGroup(updatedGroups); return withoutElements; }, CONCEPT_MAP_ENCODER); Dataset<Mapping> newMappings = conceptMaps.flatMap(ConceptMaps::expandMappingsIterator, MAPPING_ENCODER); return withConceptMaps(withoutConcepts, newMappings); }
currentGroup.setElement(new ArrayList<>(currentGroup.getElement())); break;
currentGroup.setElement(new ArrayList<>(currentGroup.getElement())); break;