public QNameApiData(DefinitionsChildId newId) { this.localname = newId.getXmlId().getDecoded(); this.namespace = newId.getNamespace().getDecoded(); } }
/** * Converts the given collection of definition children Ids to a collection of QNames by using the getQName() * method. * <p> * This is required for QNameChooser.tag */ public static Collection<QName> convertDefinitionsChildIdCollectionToQNameCollection(Collection<? extends DefinitionsChildId> col) { Collection<QName> res = new ArrayList<>(); for (DefinitionsChildId id : col) { res.add(id.getQName()); } return res; }
@Override public final boolean equals(Object o) { if (o instanceof String) { throw new IllegalStateException(); } else if (o instanceof AbstractComponentInstanceResource) { if (o.getClass().equals(this.getClass())) { // only compare if the two objects are from the same class return ((AbstractComponentInstanceResource) o).getId().equals(this.getId()); } else { throw new IllegalStateException(); } } else { throw new IllegalStateException(); } }
private List<ComponentId> getListOfIds(SortedSet<? extends DefinitionsChildId> allDefinitionsChildIds, boolean supportsNameAttribute, String full, String includeVersions) { return allDefinitionsChildIds.stream() .sorted() .map(id -> { String name = id.getXmlId().getDecoded(); Definitions definitions = null; WineryVersion version = null; if (supportsNameAttribute) { AbstractComponentInstanceResource componentInstanceResource = AbstractComponentsResource.getComponentInstanceResource(id); name = ((IHasName) componentInstanceResource).getName(); } if (Objects.nonNull(full)) { definitions = getFullComponentData(id); } if (Objects.nonNull(includeVersions)) { version = VersionUtils.getVersion(id.getXmlId().getDecoded()); } return new ComponentId(id.getXmlId().getDecoded(), name, id.getNamespace().getDecoded(), id.getQName(), definitions, version); }) .collect(Collectors.toList()); }
/** * Convenience method for getId().getNamespace() */ public final Namespace getNamespace() { return this.id.getNamespace(); }
/** * @param oldId the old id * @param newId the new id */ @Override public void rename(DefinitionsChildId oldId, DefinitionsChildId newId) throws IOException { String pathFragment = IdUtil.getURLPathFragment(oldId); NamespaceAndIdAsString namespaceAndIdAsString = new NamespaceAndIdAsString(); namespaceAndIdAsString.namespace = newId.getNamespace().getDecoded(); namespaceAndIdAsString.id = newId.getXmlId().getDecoded(); for (WebResource wr: this.repositoryResources) { // TODO: Check whether namespaceAndIdAsString is the correct data type expected at the resource ClientResponse response = wr.path(pathFragment).path("id").post(ClientResponse.class, namespaceAndIdAsString); if ((response.getClientResponseStatus() != ClientResponse.Status.NO_CONTENT) || (response.getClientResponseStatus() != ClientResponse.Status.NOT_FOUND)) { LOGGER.debug(String.format("Error %d when renaming DefinitionsChildId %s to %s at %s", response.getStatus(), oldId.toString(), newId.toString(), wr.getURI().toString())); } } }
.stream() .map(item -> new QNameWithTypeApiData( item.getXmlId().getDecoded(), item.getNamespace().getDecoded(), item.getGroup())
Path path = this.path.resolve(entry.getKey().getGroup()).resolve(entry.getKey().getNamespace().getEncoded()); try { Map<Path, TServiceTemplate> map = new X2YConverter(repository, this.path).convert(entry.getValue(), path, entry.getKey().getQName()); Optional.ofNullable(map).orElse(new LinkedHashMap<>()) .forEach((Path key, TServiceTemplate value) ->
/** * Used by children to implement getListOfAllInstances() */ protected SortedSet<Select2OptGroup> getListOfAllInstances(Class<? extends DefinitionsChildId> clazz) throws RepositoryCorruptException { Select2DataWithOptGroups data = new Select2DataWithOptGroups(); Collection<? extends DefinitionsChildId> instanceIds = RepositoryFactory.getRepository().getAllElementsReferencingGivenType(clazz, this.id.getQName()); for (DefinitionsChildId instanceId : instanceIds) { String groupText = instanceId.getNamespace().getDecoded(); String text = BackendUtils.getName(instanceId); data.add(groupText, instanceId.getQName().toString(), text); } return data.asSortedSet(); }
/** * Convenience method for getId().getXmlId() */ public final XmlId getXmlId() { return this.id.getXmlId(); }
/** * @return an instance of the requested resource * @throws NotFoundException if resource doesn't exist. */ public static AbstractComponentInstanceResource getComponentInstanceResource(DefinitionsChildId tcId) { String type = Util.getTypeForComponentId(tcId.getClass()); if (!RepositoryFactory.getRepository().exists(tcId)) { AbstractComponentsResource.LOGGER.debug("Definition child id " + tcId.toString() + " not found"); throw new NotFoundException("Definition child id " + tcId.toString() + " not found"); } Class<? extends AbstractComponentInstanceResource> newResource = AbstractComponentsResource.getComponentInstanceResourceClassForType(type); Constructor<?>[] constructors = newResource.getConstructors(); assert (constructors.length == 1); AbstractComponentInstanceResource newInstance; try { newInstance = (AbstractComponentInstanceResource) constructors[0].newInstance(tcId); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { AbstractComponentsResource.LOGGER.error("Could not instantiate sub resource " + tcId); throw new IllegalStateException("Could not instantiate sub resource", e); } return newInstance; }
@GET @Path("alldeclaredelementslocalnames") public List<String> getAllDeclaredElementsLocalNames() { return RepositoryFactory.getRepository().getXsdImportManager().getAllDeclaredElementsLocalNames().stream() .filter(namespaceAndDefinedLocalNames -> namespaceAndDefinedLocalNames.getNamespace().equals(id.getNamespace())) .flatMap(namespaceAndDefinedLocalNames -> namespaceAndDefinedLocalNames.getDefinedLocalNames().stream()) .sorted() .collect(Collectors.toList()); }
public static String getQNameWithComponentVersionOnly(DefinitionsChildId id) { Matcher m = VERSION_PATTERN.matcher(id.getXmlId().getDecoded()); String componentVersion = ""; if (m.find()) { componentVersion = Objects.nonNull(m.group(COMPONENT_VERSION_GROUP)) ? m.group(COMPONENT_VERSION_GROUP) : ""; } String nameWithoutVersion = getNameWithoutVersion(id.getQName().toString()); if (componentVersion.length() > 0) { nameWithoutVersion += WineryVersion.WINERY_VERSION_SEPARATOR + componentVersion; } return nameWithoutVersion; }
public VisualsApiData(GenericVisualAppearanceResource visuals) { IRepository repository = RepositoryFactory.getRepository(); DefinitionsChildId parent = (DefinitionsChildId) visuals.getId().getParent(); this.color = visuals.getColor(); this.typeId = parent.getQName(); this.pattern = repository.getNamespaceManager().isPatternNamespace(parent.getNamespace().getDecoded()); RepositoryFileReference iconRef = new RepositoryFileReference(visuals.getId(), Filename.FILENAME_SMALL_ICON); if (repository.exists(iconRef)) { iconUrl = visuals.getAbsoluteURL() + "16x16"; } RepositoryFileReference imageRef = new RepositoryFileReference(visuals.getId(), Filename.FILENAME_BIG_ICON); if (repository.exists(imageRef)) { imageUrl = visuals.getAbsoluteURL() + "50x50"; } }
@GET @Path("id") public String getTOSCAId() { return this.id.getXmlId().getDecoded(); }
CsarExporter.LOGGER.trace("Starting CSAR export with {}", entryId.toString());
public QName getQName() { return new QName(this.getNamespace().getDecoded(), this.getXmlId().getDecoded()); }
@Override public String toString() { QName qn = this.getQName(); return this.getClass().toString() + " / " + qn.toString(); }
@GET @Path("alldefinedtypeslocalnames") public List<String> getAllDefinedTypesLocalNames() { return RepositoryFactory.getRepository().getXsdImportManager().getAllDefinedTypesLocalNames().stream() .filter(namespaceAndDefinedLocalNames -> namespaceAndDefinedLocalNames.getNamespace().equals(id.getNamespace())) .flatMap(namespaceAndDefinedLocalNames -> namespaceAndDefinedLocalNames.getDefinedLocalNames().stream()) .sorted() .collect(Collectors.toList()); } }