Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Feature/properties in boundary definitions #113

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ protected void setWPDElement(WinerysPropertiesDefinition res) {
}

protected void setWPDNamespace(WinerysPropertiesDefinition res) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could actually implement it on this level since the methods are identical. To be able to use the getTargetNamespace method, you can check if the current object is an instance of HasTargetNamespace and cast it. Otherwise, you could use a default namespace.

// bo be overridden by subclasses willing to use getWinerysPropertiesDefinition()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be marked as abstract then, to force said overriding? This class is already abstract so we're not giving up anything for that

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not sure if all TExtensibleElements actually need WPD support, since initially only TEntityType supported them. This is an attempt to reuse the method in both TEntityTypes and TServiceTemplates without duplicating it and at the same time without putting additional requirements on TExtensibleElements.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to have this "abstract" method. The implementations in both are similar and you could check if the current class is an instance of HasTargetNamespace, and otherwise use a default one

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's a good solution if a namespace has to be set in the same way for both TEntityType and TServiceTemplate (currently setWPDNamespace is identical, so I assume there's no need for different implementations)

// Template method pattern
}

@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.eclipse.winery.repository.rest.resources._support.IHasName;
import org.eclipse.winery.repository.rest.resources._support.dataadapter.injectionadapter.InjectorReplaceData;
import org.eclipse.winery.repository.rest.resources._support.dataadapter.injectionadapter.InjectorReplaceOptions;
import org.eclipse.winery.repository.rest.resources.apiData.PropertiesDefinitionResourceApiData;
import org.eclipse.winery.repository.rest.resources.servicetemplates.boundarydefinitions.BoundaryDefinitionsResource;
import org.eclipse.winery.repository.rest.resources.servicetemplates.plans.PlansResource;
import org.eclipse.winery.repository.rest.resources.servicetemplates.propertiesdefinition.BoundaryDefsPropertiesDefinitionResource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,10 @@
import io.github.adr.embedded.ADR;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;

public class BoundaryDefinitionsPropertiesResource {
private static final Logger LOGGER = LoggerFactory.getLogger(BoundaryDefinitionsPropertiesResource.class);


private AbstractComponentInstanceResource res;
private TServiceTemplate template;

Expand All @@ -58,14 +55,9 @@ public Response getProperties() {
TBoundaryDefinitions.Properties props = this.template.getBoundaryDefinitions().getProperties();
if (wpd == null) {
// no Winery special treatment, just return the XML properties
// These can be null resulting in 200 No Content at the caller
if (props == null) {
return Response.ok().type(MediaType.APPLICATION_XML).build();
} else {
/*if (props.getAny() == null) {
LOGGER.debug("XML properties expected, but none found. Returning empty JSON.");
return Response.noContent().type(MediaType.APPLICATION_XML).build();
}*/
try {
@ADR(6)
String xmlAsString = BackendUtils.getXMLAsString(TBoundaryDefinitions.Properties.class, props, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.eclipse.winery.repository.rest.resources.servicetemplates.boundarydefinitions;

import java.util.List;
import java.util.Map;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
Expand All @@ -36,7 +35,6 @@
import org.eclipse.winery.model.tosca.TBoundaryDefinitions.Requirements;
import org.eclipse.winery.model.tosca.TCapabilityRef;
import org.eclipse.winery.model.tosca.TRequirementRef;
import org.eclipse.winery.model.tosca.utils.ModelUtilities;
import org.eclipse.winery.repository.rest.RestUtils;
import org.eclipse.winery.repository.rest.resources.servicetemplates.ServiceTemplateResource;
import org.eclipse.winery.repository.rest.resources.servicetemplates.boundarydefinitions.interfaces.InterfacesResource;
Expand All @@ -45,8 +43,6 @@
import org.eclipse.winery.repository.rest.resources.servicetemplates.boundarydefinitions.reqscaps.RequirementsResource;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.w3c.dom.Document;

public class BoundaryDefinitionsResource {

Expand Down