/** * This is a special method for Winery. Winery allows to define a property by specifying name/value values. Instead * of parsing the XML contained in TNodeType, this method is a convenience method to access this information * <p> * The return type "Properties" is used because of the key/value properties. * * @param template the node template to get the associated properties */ public static Map<String, String> getPropertiesKV(TEntityTemplate template) { if (template.getProperties() != null) { return template.getProperties().getKVProperties(); } else { return null; } }
@PUT @Consumes(MediaType.APPLICATION_JSON) public Response setProperties(Map<String, String> properties) { this.template.getProperties().setKVProperties(properties); return RestUtils.persist(this.res); }
public boolean propertiesCompatible(ToscaEntity left, ToscaEntity right) { boolean propertiesCompatible = true; TEntityTemplate[] templates = getTemplates(left, right); TEntityTemplate detectorElement = templates[0]; TEntityTemplate candidate = templates[1]; if (Objects.nonNull(detectorElement.getProperties()) && Objects.nonNull(candidate.getProperties()) && // the implementation (currently) works for KV properties only Objects.nonNull(detectorElement.getProperties().getKVProperties()) && Objects.nonNull(candidate.getProperties().getKVProperties())) { Map<String, String> detectorProperties = detectorElement.getProperties().getKVProperties(); Map<String, String> candidateProperties = candidate.getProperties().getKVProperties(); propertiesCompatible = detectorProperties.entrySet().stream() .allMatch(entry -> { if (Objects.nonNull(entry.getValue()) && !entry.getValue().isEmpty()) { String refProp = candidateProperties.get(entry.getKey()); if (entry.getValue().equalsIgnoreCase("*")) { // if the detector defines a wildcard, the property must be set in the candidate return !refProp.isEmpty(); } else { // if the detector defines a specific value, the candidate's property must match return entry.getValue().equalsIgnoreCase(refProp); } } return true; }); } return propertiesCompatible; }
TEntityType tempType = RepositoryFactory.getRepository().getTypeForTemplate(this.template); WinerysPropertiesDefinition wpd = tempType.getWinerysPropertiesDefinition(); TEntityTemplate.Properties props = this.template.getProperties(); if (wpd == null) { Map<String, String> kvProperties = this.template.getProperties().getKVProperties(); return Response.ok().entity(kvProperties).type(MediaType.APPLICATION_JSON).build();
TEntityTemplate.Properties properties = template.getProperties(); if (properties != null) { Object any = properties.getInternalAny(); throw e; template.getProperties().setAny(doc.getDocumentElement());
public Builder(TEntityTemplate entityTemplate) { super(entityTemplate); this.type = entityTemplate.getType(); this.properties = entityTemplate.getProperties(); this.addPropertyConstraints(entityTemplate.getPropertyConstraints()); }
public void visit(TEntityTemplate entityTemplate) { this.visit((HasId) entityTemplate); final TEntityTemplate.Properties properties = entityTemplate.getProperties(); if (properties != null) { properties.accept(this); } final TEntityTemplate.PropertyConstraints propertyConstraints = entityTemplate.getPropertyConstraints(); if (propertyConstraints != null) { propertyConstraints.accept(this); } // meta model does not offer more children }
@Override public void visit(TEntityTemplate entityTemplate) { final TEntityTemplate.PropertyConstraints propertyConstraints = entityTemplate.getPropertyConstraints(); if ((propertyConstraints != null) && propertyConstraints.getPropertyConstraint().isEmpty()) { entityTemplate.setPropertyConstraints(null); } TEntityTemplate.Properties properties = entityTemplate.getProperties(); if ((properties != null) && (properties.getInternalAny() == null)) { entityTemplate.setProperties(null); } super.visit(entityTemplate); }
final TEntityType.PropertiesDefinition propertiesDefinition = entityType.getPropertiesDefinition(); if ((winerysPropertiesDefinition != null) || (propertiesDefinition != null)) { final TEntityTemplate.Properties properties = entityTemplate.getProperties(); if (properties == null) { printAndAddError(id, "Properties required, but no properties defined"); Map<String, String> kvProperties = entityTemplate.getProperties().getKVProperties(); if (kvProperties.isEmpty()) { printAndAddError(id, "Properties required, but no properties set (any case)");