Skip to content

Commit

Permalink
Remove JSON serialization information from XML model
Browse files Browse the repository at this point in the history
  • Loading branch information
Vogel612 committed Jul 17, 2020
1 parent 285688a commit 14c43f5
Show file tree
Hide file tree
Showing 21 changed files with 2 additions and 99 deletions.
Expand Up @@ -27,16 +27,6 @@
</properties>

<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${org.glassfish.jxb}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jdt/org.eclipse.jdt.annotation -->
<dependency>
<groupId>org.eclipse.jdt</groupId>
Expand Down
Expand Up @@ -13,8 +13,6 @@
*******************************************************************************/
package org.eclipse.winery.model.tosca.xml;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.xml.bind.annotation.XmlTransient;

public interface HasIdInIdOrNameField {
Expand All @@ -23,7 +21,6 @@ public interface HasIdInIdOrNameField {
* Returns the id
*/
@XmlTransient
@JsonIgnore
default String getIdFromIdOrNameField() {
if (this instanceof HasId) {
return ((HasId) this).getId();
Expand Down
Expand Up @@ -13,8 +13,6 @@
*******************************************************************************/
package org.eclipse.winery.model.tosca.xml;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.xml.bind.annotation.XmlTransient;
import javax.xml.namespace.QName;

Expand All @@ -27,7 +25,6 @@ public interface HasType {
* @return the QName of the type with full namespace, never null (according to spec)
*/
@XmlTransient
@JsonIgnore
QName getTypeAsQName();

/**
Expand Down
Expand Up @@ -22,19 +22,16 @@

import org.eclipse.winery.model.tosca.xml.visitor.Visitor;

import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.eclipse.jdt.annotation.NonNull;

public abstract class OTPrmMapping extends HasId implements Serializable {

@JsonIdentityReference(alwaysAsId = true)
@XmlAttribute(name = "detectorNode", required = true)
@XmlIDREF
@XmlSchemaType(name = "IDREF")
@NonNull
private TEntityTemplate detectorNode;

@JsonIdentityReference(alwaysAsId = true)
@XmlAttribute(name = "refinementNode", required = true)
@XmlIDREF
@XmlSchemaType(name = "IDREF")
Expand Down
Expand Up @@ -20,7 +20,6 @@
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.eclipse.jdt.annotation.NonNull;

@XmlAccessorType(XmlAccessType.FIELD)
Expand All @@ -31,7 +30,6 @@ public class OTTestRefinementModel extends OTRefinementModel {
private TTopologyTemplate testFragment;

@NonNull
@JsonIgnore
@XmlTransient
public TTopologyTemplate getRefinementTopology() {
if (testFragment == null) {
Expand Down
Expand Up @@ -27,7 +27,6 @@
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

Expand All @@ -51,7 +50,6 @@ public class OTTopologyFragmentRefinementModel extends OTRefinementModel {
protected List<OTDeploymentArtifactMapping> deploymentArtifactMappings;

@NonNull
@JsonIgnore
@XmlTransient
public TTopologyTemplate getRefinementTopology() {
if (refinementStructure == null) {
Expand Down
Expand Up @@ -13,22 +13,10 @@
*******************************************************************************/
package org.eclipse.winery.model.tosca.xml;

import com.fasterxml.jackson.annotation.*;
import io.github.adr.embedded.ADR;

import javax.xml.namespace.QName;

@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
// see https://stackoverflow.com/q/44789227/873282 for an explanation for this solution
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
property = "fakeJacksonType")
@JsonSubTypes( {
@JsonSubTypes.Type(value = TRequirement.class, name = "requirement"),
@JsonSubTypes.Type(value = TCapability.class, name = "capability"),
@JsonSubTypes.Type(value = TNodeTemplate.class, name = "nodetemplate")
})
public abstract class RelationshipSourceOrTarget extends TEntityTemplate {

public RelationshipSourceOrTarget() {
Expand All @@ -43,7 +31,6 @@ public RelationshipSourceOrTarget(Builder builder) {
super(builder);
}

@JsonIgnore
public abstract String getFakeJacksonType();

@ADR(11)
Expand Down
Expand Up @@ -25,16 +25,10 @@

import org.eclipse.winery.model.tosca.xml.visitor.Visitor;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.eclipse.jdt.annotation.NonNull;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "tCapability")
@JsonTypeInfo(
defaultImpl = TCapability.class,
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
property = "fakeJacksonType")
public class TCapability extends RelationshipSourceOrTarget {

@XmlAttribute(name = "name", required = true)
Expand Down
Expand Up @@ -34,7 +34,6 @@

import org.eclipse.winery.model.tosca.xml.visitor.Visitor;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.github.adr.embedded.ADR;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
Expand Down Expand Up @@ -123,7 +122,6 @@ public void accept(Visitor visitor) {
* Convenience method for <code>this.getServiceTemplateOrNodeTypeOrNodeTypeImplementation().get(0)</code>
*/
@XmlTransient
@JsonIgnore
public TExtensibleElements getElement() {
return this.getServiceTemplateOrNodeTypeOrNodeTypeImplementation().get(0);
}
Expand Down Expand Up @@ -174,7 +172,6 @@ public List<TExtensibleElements> getServiceTemplateOrNodeTypeOrNodeTypeImplement
return this.serviceTemplateOrNodeTypeOrNodeTypeImplementation;
}

@JsonIgnore
@NonNull
public List<TRelationshipType> getRelationshipTypes() {
return getServiceTemplateOrNodeTypeOrNodeTypeImplementation().stream()
Expand All @@ -183,7 +180,6 @@ public List<TRelationshipType> getRelationshipTypes() {
.collect(Collectors.toList());
}

@JsonIgnore
@NonNull
public List<TRelationshipTypeImplementation> getRelationshipTypeImplementations() {
return getServiceTemplateOrNodeTypeOrNodeTypeImplementation().stream()
Expand All @@ -192,7 +188,6 @@ public List<TRelationshipTypeImplementation> getRelationshipTypeImplementations(
.collect(Collectors.toList());
}

@JsonIgnore
@NonNull
public List<TArtifactTemplate> getArtifactTemplates() {
return getServiceTemplateOrNodeTypeOrNodeTypeImplementation().stream()
Expand All @@ -201,7 +196,6 @@ public List<TArtifactTemplate> getArtifactTemplates() {
.collect(Collectors.toList());
}

@JsonIgnore
@NonNull
public List<TPolicyTemplate> getPolicyTemplates() {
return getServiceTemplateOrNodeTypeOrNodeTypeImplementation().stream()
Expand All @@ -210,7 +204,6 @@ public List<TPolicyTemplate> getPolicyTemplates() {
.collect(Collectors.toList());
}

@JsonIgnore
@NonNull
public List<TServiceTemplate> getServiceTemplates() {
return getServiceTemplateOrNodeTypeOrNodeTypeImplementation().stream()
Expand All @@ -219,7 +212,6 @@ public List<TServiceTemplate> getServiceTemplates() {
.collect(Collectors.toList());
}

@JsonIgnore
@NonNull
public List<TArtifactType> getArtifactTypes() {
return getServiceTemplateOrNodeTypeOrNodeTypeImplementation().stream()
Expand All @@ -228,16 +220,14 @@ public List<TArtifactType> getArtifactTypes() {
.collect(Collectors.toList());
}

@JsonIgnore
@NonNull
public List<TCapabilityType> getCapabilityTypes() {
return getServiceTemplateOrNodeTypeOrNodeTypeImplementation().stream()
.filter(x -> x instanceof TCapabilityType)
.map(TCapabilityType.class::cast)
.collect(Collectors.toList());
}

@JsonIgnore

@NonNull
public List<TNodeType> getNodeTypes() {
return getServiceTemplateOrNodeTypeOrNodeTypeImplementation().stream()
Expand All @@ -246,7 +236,6 @@ public List<TNodeType> getNodeTypes() {
.collect(Collectors.toList());
}

@JsonIgnore
@NonNull
public List<TNodeTypeImplementation> getNodeTypeImplementations() {
return getServiceTemplateOrNodeTypeOrNodeTypeImplementation().stream()
Expand All @@ -255,7 +244,6 @@ public List<TNodeTypeImplementation> getNodeTypeImplementations() {
.collect(Collectors.toList());
}

@JsonIgnore
@NonNull
public List<TRequirementType> getRequirementTypes() {
return getServiceTemplateOrNodeTypeOrNodeTypeImplementation().stream()
Expand All @@ -264,7 +252,6 @@ public List<TRequirementType> getRequirementTypes() {
.collect(Collectors.toList());
}

@JsonIgnore
@NonNull
public List<TPolicyType> getPolicyTypes() {
return getServiceTemplateOrNodeTypeOrNodeTypeImplementation().stream()
Expand Down
Expand Up @@ -36,7 +36,6 @@
import org.eclipse.winery.model.tosca.xml.constants.Namespaces;
import org.eclipse.winery.model.tosca.xml.visitor.Visitor;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.github.adr.embedded.ADR;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
Expand Down Expand Up @@ -164,7 +163,6 @@ public Object getAny() {
* Returns the internal any object without any K/V treatment. Required to patch JSON data received by clients
*/
@Nullable
@JsonIgnore
public Object getInternalAny() {
return any;
}
Expand Down
Expand Up @@ -32,7 +32,6 @@
import org.eclipse.winery.model.tosca.xml.kvproperties.WinerysPropertiesDefinition;
import org.eclipse.winery.model.tosca.xml.visitor.Visitor;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.github.adr.embedded.ADR;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
Expand Down Expand Up @@ -143,7 +142,6 @@ public void setName(@Nullable String value) {
this.name = value;
}

@JsonIgnore
@NonNull
public QName getQName() {
return QName.valueOf("{" + this.targetNamespace + "}" + this.name);
Expand Down Expand Up @@ -194,7 +192,6 @@ public void setTargetNamespace(@Nullable String value) {
* null if no Winery specific KV properties are defined for the given entity type
*/
@XmlTransient
@JsonIgnore
public WinerysPropertiesDefinition getWinerysPropertiesDefinition() {
// similar implementation as org.eclipse.winery.repository.resources.entitytypes.properties.PropertiesDefinitionResource.getListFromEntityType(TEntityType)
WinerysPropertiesDefinition res = null;
Expand Down
Expand Up @@ -28,7 +28,6 @@
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.namespace.QName;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

Expand Down Expand Up @@ -103,7 +102,6 @@ public void setTargetNamespace(String value) {
this.targetNamespace = value;
}

@JsonIgnore
public QName getQName() {
return QName.valueOf("{" + this.targetNamespace + "}" + this.name);
}
Expand Down
Expand Up @@ -27,7 +27,6 @@
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

Expand Down Expand Up @@ -165,9 +164,8 @@ public static class NodeOperation implements Serializable {
@XmlAttribute(name = "nodeRef", required = true)
@XmlIDREF
@XmlSchemaType(name = "IDREF")
@JsonIdentityReference(alwaysAsId = true)
protected Object nodeRef;

@XmlAttribute(name = "interfaceName", required = true)
@XmlSchemaType(name = "anyURI")
protected String interfaceName;
Expand Down Expand Up @@ -257,7 +255,6 @@ public static class Plan implements Serializable {
@XmlAttribute(name = "planRef", required = true)
@XmlIDREF
@XmlSchemaType(name = "IDREF")
@JsonIdentityReference(alwaysAsId = true)
protected Object planRef;

/**
Expand Down Expand Up @@ -304,7 +301,6 @@ public static class RelationshipOperation implements Serializable {
@XmlAttribute(name = "relationshipRef", required = true)
@XmlIDREF
@XmlSchemaType(name = "IDREF")
@JsonIdentityReference(alwaysAsId = true)
protected Object relationshipRef;

@XmlAttribute(name = "interfaceName", required = true)
Expand Down
Expand Up @@ -31,7 +31,6 @@
import org.eclipse.winery.model.tosca.xml.constants.Namespaces;
import org.eclipse.winery.model.tosca.xml.visitor.Visitor;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

Expand All @@ -42,11 +41,6 @@
"policies",
"deploymentArtifacts"
})
@JsonTypeInfo(
defaultImpl = TNodeTemplate.class,
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
property = "fakeJacksonType")
public class TNodeTemplate extends RelationshipSourceOrTarget implements HasPolicies {

@XmlElement(name = "Requirements")
Expand Down
Expand Up @@ -32,8 +32,6 @@

import org.eclipse.winery.model.tosca.xml.visitor.Visitor;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.w3c.dom.Element;
Expand All @@ -46,7 +44,6 @@
"planModel",
"planModelReference"
})
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
public class TPlan extends TExtensibleElements {
@XmlElement(name = "Precondition")
protected TCondition precondition;
Expand Down

0 comments on commit 14c43f5

Please sign in to comment.