@Override public GenericImportResource getComponentInstanceResource(String namespace, String id, boolean encoded) { GenericImportId iId = new GenericImportId(namespace, id, encoded, this.type); return new GenericImportResource(iId); }
/** * Generates an ImportId based on an TImport object The import has to be an * import created by winery. This method uses the convention that the id is * derived from the location * * @param i the TImport element to derive an id from */ public GenericImportId(TImport i) { this(i.getNamespace(), GenericImportId.getId(i), false, i.getImportType()); }
default Collection<DefinitionsChildId> getReferencingDefinitionsChildIds(GenericImportId id) { Collection<DefinitionsChildId> ids = new HashSet<>(); // ArtifactTypes > PropertiesDefinition ids.addAll(this.getAllElementsReferencingGivenType(ArtifactTypeId.class, id.getQName())); // CapabilityTypes > PropertiesDefinition ids.addAll(this.getAllElementsReferencingGivenType(CapabilityTypeId.class, id.getQName())); // NodeTypes > PropertiesDefinition ids.addAll(this.getAllElementsReferencingGivenType(NodeTypeId.class, id.getQName())); // PolicyTypes > PropertiesDefinition ids.addAll(this.getAllElementsReferencingGivenType(PolicyTypeId.class, id.getQName())); // RelationshipTypes > PropertiesDefinition ids.addAll(this.getAllElementsReferencingGivenType(RelationshipTypeId.class, id.getQName())); // RequirementTypes > PropertiesDefinition ids.addAll(this.getAllElementsReferencingGivenType(RequirementTypeId.class, id.getQName())); return ids; }
if (element.getNamespaceURI().equals(XMLConstants.W3C_XML_SCHEMA_NS_URI)) { ns = element.getAttribute("targetNamespace"); importId = new XSDImportId(ns, id, false); } else { importId = new GenericImportId(ns, id, false, element.getNamespaceURI());
GenericImportId i = (GenericImportId) id; String res = "imports/"; res = res + Util.URLencode(i.getType()) + "/"; res = res + i.getNamespace().getEncoded() + "/"; res = res + i.getXmlId().getEncoded() + "/"; return res; } else if (id instanceof DefinitionsChildId) {
public static void storeTypes(Path path, String namespace, String id) { LOGGER.debug("Store type: {}", id); try { MediaType mediaType = MediaTypes.MEDIATYPE_XSD; TImport.Builder builder = new TImport.Builder(Namespaces.XML_NS); builder.setNamespace(namespace); builder.setLocation(id + ".xsd"); GenericImportId rid = new XSDImportId(namespace, id, false); TDefinitions definitions = BackendUtils.createWrapperDefinitions(rid); definitions.getImport().add(builder.build()); CsarImporter.storeDefinitions(rid, definitions); RepositoryFileReference ref = BackendUtils.getRefOfDefinitions(rid); List<File> files = Files.list(path).filter(Files::isRegularFile) .map(Path::toFile).collect(Collectors.toList()); for (File file : files) { BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file)); RepositoryFileReference fileRef = new RepositoryFileReference(ref.getParent(), file.getName()); RepositoryFactory.getRepository().putContentToFile(fileRef, stream, mediaType); } } catch (IllegalArgumentException | IOException e) { throw new IllegalStateException(e); } }
/** * Finds out all imports belonging to the given namespace */ private Set<XSDImportId> getImportsOfNamespace(final Namespace namespace) { Objects.requireNonNull(namespace); // implemented using a straight-forward solution: get ALL XSD definitions and filter out the matching ones Set<XSDImportId> allImports = RepositoryFactory.getRepository().getAllDefinitionsChildIds(XSDImportId.class); return allImports.stream().filter(imp -> imp.getNamespace().equals(namespace)).collect(Collectors.toSet()); }
rid = new XSDImportId(namespace, id, false); } else { rid = new GenericImportId(namespace, id, false, type);
if (Util.isRelativeURI(loc)) { GenericImportId iid = new GenericImportId(i); String fileName = Util.getLastURIPart(loc); fileName = Util.URLdecode(fileName);
XSDImportId importId = new XSDImportId(winerysPropertiesDefinition.getNamespace(), elementName, false); try { RepositoryFactory.getRepository().forceDelete(importId);
/** * @param getType true: XSConstants.TYPE_DEFINITION; false: XSConstants.ELEMENT_DECLARATION */ private List<NamespaceAndDefinedLocalNames> getAllXsdDefinitions(boolean getType) { MutableMultimap<Namespace, String> data = Multimaps.mutable.list.empty(); SortedSet<XSDImportId> allImports = RepositoryFactory.getRepository().getAllDefinitionsChildIds(XSDImportId.class); for (XSDImportId id : allImports) { final List<String> allDefinedLocalNames = getAllDefinedLocalNames(id, getType); data.putAll(id.getNamespace(), allDefinedLocalNames); } List<NamespaceAndDefinedLocalNames> result = Lists.mutable.empty(); data.forEachKeyMultiValues((namespace, strings) -> { final NamespaceAndDefinedLocalNames namespaceAndDefinedLocalNames = new NamespaceAndDefinedLocalNames(namespace); strings.forEach(localName -> namespaceAndDefinedLocalNames.addLocalName(localName)); result.add(namespaceAndDefinedLocalNames); }); return result; }
if (id.getNamespace().getDecoded().equals(item.getNamespace())) { result.add(item.getName());