/** * @return null if no explicit left is set */ public static String getTop(TNodeTemplate nodeTemplate) { Map<QName, String> otherAttributes = nodeTemplate.getOtherAttributes(); return otherAttributes.get(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "y")); }
/** * Target Label is not case sensitive -> set to lowercase. */ public static void setTargetLabel(TNodeTemplate nodeTemplate, String targetLabel) { Objects.requireNonNull(nodeTemplate); Objects.requireNonNull(targetLabel); Map<QName, String> otherAttributes = nodeTemplate.getOtherAttributes(); otherAttributes.put(QNAME_LOCATION, targetLabel.toLowerCase()); }
/** * In the JSON, also output this direct child of the node template object. Therefore, no JsonIgnore annotation. */ @XmlTransient @Nullable public String getX() { Map<QName, String> otherNodeTemplateAttributes = this.getOtherAttributes(); return otherNodeTemplateAttributes.get(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "x")); }
@Path("y") @GET @ApiOperation(value = "@return the y coordinate of the node template") public String getY() { Map<QName, String> otherAttributes = this.o.getOtherAttributes(); return otherAttributes.get(this.qnameY); }
/** * In the JSON, also output this direct child of the node template object. Therefore, no JsonIgnore annotation. */ @XmlTransient @Nullable public String getY() { Map<QName, String> otherNodeTemplateAttributes = this.getOtherAttributes(); return otherNodeTemplateAttributes.get(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "y")); }
@Path("x") @GET @ApiOperation(value = "@return the x coordinate of the node template") public String getX() { Map<QName, String> otherAttributes = this.o.getOtherAttributes(); return otherAttributes.get(this.qnameX); }
/** * Target label is not present if - empty string - undefined - null Target Label is not case sensitive -> always * lower case. */ public static Optional<String> getTargetLabel(TNodeTemplate nodeTemplate) { if (nodeTemplate == null) { return Optional.empty(); } Map<QName, String> otherAttributes = nodeTemplate.getOtherAttributes(); String targetLabel = otherAttributes.get(QNAME_LOCATION); if (targetLabel != null && (targetLabel.equals("undefined") || targetLabel.equals(""))) { return Optional.empty(); } return Optional.ofNullable(targetLabel).map(String::toLowerCase); }
/** * Sets the top coordinate of a {@link TNodeTemplate}. When receiving the JSON, this method ensures that (i) the "y" * property can be handled and (ii) the Y coordinate is written correctly in the extension namespace. * * @param y the value of the coordinate to be set */ public void setY(@NonNull String y) { Map<QName, String> otherNodeTemplateAttributes = this.getOtherAttributes(); otherNodeTemplateAttributes.put(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "y"), y); }
/** * Sets the top coordinate of a {@link TNodeTemplate}. When receiving the JSON, this method ensures that (i) the "y" * property can be handled and (ii) the Y coordinate is written correctly in the extension namespace. * * @param x the value of the x-coordinate to be set */ public void setX(@NonNull String x) { Objects.requireNonNull(x); Map<QName, String> otherNodeTemplateAttributes = this.getOtherAttributes(); otherNodeTemplateAttributes.put(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "x"), x); }
@Path("x") @PUT public Response setX(String x) { this.o.getOtherAttributes().put(this.qnameX, x); return RestUtils.persist(this.res); }
@Path("y") @PUT public Response setY(String y) { this.o.getOtherAttributes().put(this.qnameY, y); return RestUtils.persist(this.res); }
public static Optional<Integer> getLeft(TNodeTemplate nodeTemplate) { Map<QName, String> otherAttributes = nodeTemplate.getOtherAttributes(); String x = otherAttributes.get(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "x")); if (x == null) { return Optional.empty(); } Float floatValue; try { floatValue = Float.parseFloat(x); } catch (NumberFormatException e) { LOGGER.debug("Could not parse x value", e); return Optional.empty(); } return Optional.of(floatValue.intValue()); }