Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/ldmgeneration'
Browse files Browse the repository at this point in the history
  • Loading branch information
lharzenetter committed Jan 8, 2021
2 parents c075b82 + f010f0b commit fde6ef4
Show file tree
Hide file tree
Showing 14 changed files with 303 additions and 269 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class InheritanceUtils {
* @returns newKVProperties: KV Properties as Object
*/
static getKVProperties(type: any): any {
const newKVProperies = {};
const newKVProperties = {};
const kvProperties = type.full.serviceTemplateOrNodeTypeOrNodeTypeImplementation[0].propertiesDefinition.propertyDefinitionKVList;
for (const obj of kvProperties) {
const key = obj.key;
Expand All @@ -190,9 +190,9 @@ export class InheritanceUtils {
} else {
value = obj.value;
}
newKVProperies[key] = value;
newKVProperties[key] = value;
}
return newKVProperies;
return newKVProperties;
}

static hasKVPropDefinition(element: EntityType): boolean {
Expand Down Expand Up @@ -235,21 +235,22 @@ export class InheritanceUtils {
*/
static getDefaultPropertiesFromEntityTypes(qName: string, entities: EntityType[]): any {
for (const element of entities) {
const selectedType = element.full.serviceTemplateOrNodeTypeOrNodeTypeImplementation[0];
if (element.qName === qName) {
// if propertiesDefinition is defined it's a XML property
// FIXME this needs to correctly handle the type option for defining XML properties
if (element.full.serviceTemplateOrNodeTypeOrNodeTypeImplementation[0].propertiesDefinition
&& element.full.serviceTemplateOrNodeTypeOrNodeTypeImplementation[0].propertiesDefinition.element) {
if (selectedType.propertiesDefinition
&& selectedType.propertiesDefinition.element) {
return {
propertyType: PropertyDefinitionType.XML,
any: element.full.serviceTemplateOrNodeTypeOrNodeTypeImplementation[0].propertiesDefinition.element
any: selectedType.propertiesDefinition.element
};
// properties definition contains yaml properties
} else if (element.full.serviceTemplateOrNodeTypeOrNodeTypeImplementation[0].propertiesDefinition
&& element.full.serviceTemplateOrNodeTypeOrNodeTypeImplementation[0].propertiesDefinition.properties) {
// properties definition contains yaml properties
} else if (selectedType.propertiesDefinition
&& selectedType.propertiesDefinition.properties) {
let inheritedProperties = {};
if (InheritanceUtils.hasParentType(element)) {
let parent = element.full.serviceTemplateOrNodeTypeOrNodeTypeImplementation[0].derivedFrom.typeRef;
let parent = selectedType.derivedFrom.typeRef;
let continueFlag;

while (parent) {
Expand Down Expand Up @@ -288,7 +289,7 @@ export class InheritanceUtils {
} else { // otherwise KV properties or no properties at all
let inheritedProperties = {};
if (InheritanceUtils.hasParentType(element)) {
let parent = element.full.serviceTemplateOrNodeTypeOrNodeTypeImplementation[0].derivedFrom.typeRef;
let parent = selectedType.derivedFrom.typeRef;
let continueFlag;

while (parent) {
Expand Down Expand Up @@ -321,10 +322,19 @@ export class InheritanceUtils {

const mergedProperties = { ...inheritedProperties, ...typeProperties };

return {
const properties = {
propertyType: PropertyDefinitionType.KV,
kvproperties: { ...mergedProperties }
kvproperties: { ...mergedProperties },
};

return InheritanceUtils.hasKVPropDefinition(element) && selectedType.propertiesDefinition.elementName
&& selectedType.propertiesDefinition.namespace
? {
...properties,
elementName: selectedType.propertiesDefinition.elementName,
namespace: selectedType.propertiesDefinition.namespace
}
: properties;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,9 @@ public int hashCode() {
// Xml transformation is done by XmlJavaTypeAdapter, thus no XML configuration whatsoever
public static class WineryKVProperties extends Properties {

@JsonIgnore
@Nullable
private String namespace = null;

@JsonIgnore
@Nullable
private String elementName = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,12 @@ public void setKVProperties(Map<String, String> properties) {

@ADR(12)
public void setKVProperties(@Nullable String namespace, @Nullable String elementName, Map<String, String> properties) {
if (elementName == null || elementName.equals("")) {
if (elementName == null || elementName.isEmpty()) {
elementName = "Properties";
}
if (namespace == null || namespace.isEmpty()) {
namespace = Namespaces.EXAMPLE_NAMESPACE_URI;
}
Objects.requireNonNull(properties);
Element el = (Element) any;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ public Response createPlaceholderSubstituteVersion() throws IOException, Splitti
WineryVersion newVersion = new WineryVersion(
"_substituted_" + version.toString(),
1,
0
1
);

ServiceTemplateId newId = new ServiceTemplateId(id.getNamespace().getDecoded(),
Expand Down Expand Up @@ -687,14 +687,15 @@ public List<Response> createParticipantsVersion() throws IOException {
WineryVersion newVersion = new WineryVersion(
participant.getName() + "-" + version.toString().replace("gdm", "ldm"),
1,
0
1
);

List<OTParticipant> newParticipantList = new ArrayList<>();
newParticipantList.addAll(topologyTemplate.getParticipants());

// create list of tags to add to service template
TTags tTagList = new TTags();
tTagList.getTag().addAll(tags);

// new tag to define participant of service template
TTag participantTag = new TTag();
Expand Down Expand Up @@ -746,7 +747,7 @@ public Response createNewPlaceholderVersion() throws IOException {
WineryVersion newVersion = new WineryVersion(
"gdm-" + version.toString(),
1,
0
1
);

IRepository repository = RepositoryFactory.getRepository();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public void getServicetemplate() throws Exception {
@Test
public void getServiceTemplateWithProperties() throws Exception {
this.setRevisionTo("3465576f5b46079bb26f5c8e93663424440421a0");
this.assertGet("servicetemplates/http%253A%252F%252Fwinery.opentosca.org%252Ftest%252Fservicetemplates%252Fponyuniverse%252Fdriverinjection/DriverInjectionTest/topologytemplate", "entitytypes/servicetemplates/DriverInjection.json");
this.assertGet("servicetemplates/http%253A%252F%252Fwinery.opentosca.org%252Ftest%252Fservicetemplates%252Fponyuniverse%252Fdriverinjection/DriverInjectionTest/topologytemplate",
"entitytypes/servicetemplates/DriverInjection.json");
}

@Test
Expand Down Expand Up @@ -119,7 +120,8 @@ public void getXaasPackagerData() throws Exception {
@Test
public void checkJsonOfServiceTemplateMinimalExampleWithAllPropertyVariants() throws Exception {
this.setRevisionTo("origin/plain");
this.assertGet("servicetemplates/http%253A%252F%252Fplain.winery.opentosca.org%252Fservicetemplates/ServiceTemplateMinimalExampleWithAllPropertyVariants", "servicetemplates/plain-ServiceTemplateMinimalExampleWithAllPropertyVariants.json");
this.assertGet("servicetemplates/http%253A%252F%252Fplain.winery.opentosca.org%252Fservicetemplates/ServiceTemplateMinimalExampleWithAllPropertyVariants",
"servicetemplates/plain-ServiceTemplateMinimalExampleWithAllPropertyVariants.json");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public void getServicetemplate() throws Exception {
@Test
public void getComponentInstanceJSON() throws Exception {
this.setRevisionTo("3fe0df76e98d46ead68295920e5d1cf1354bdea1");
this.assertGet("servicetemplates/http%253A%252F%252Fwinery.opentosca.org%252Ftest%252Fservicetemplates%252Ffruits/baobab_serviceTemplate/topologytemplate/", "servicetemplates/baobab_topologytemplate.json");
this.assertGet("servicetemplates/http%253A%252F%252Fwinery.opentosca.org%252Ftest%252Fservicetemplates%252Ffruits/baobab_serviceTemplate/topologytemplate/",
"servicetemplates/baobab_topologytemplate.json");
}

@Test
Expand Down Expand Up @@ -87,7 +88,8 @@ public void apacheSparkAppOnVspheretopologyTemplateUpdateWithEmptyListsGetTheLis
@Test
public void farmTopologyTemplateIsCorrectlyReturnAsJson() throws Exception {
this.setRevisionTo("2d35f0d3c15b384c53df10967164d97e4a7dd6f2");
this.assertGet("servicetemplates/http%253A%252F%252Fwinery.opentosca.org%252Ftest%252Fservicetemplates%252Ffruits/farm/topologytemplate/", "servicetemplates/farm_topologytemplate.json");
this.assertGet("servicetemplates/http%253A%252F%252Fwinery.opentosca.org%252Ftest%252Fservicetemplates%252Ffruits/farm/topologytemplate/",
"servicetemplates/farm_topologytemplate.json");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,6 @@
],
"otherAttributes": {
},
"relationshipTemplates": [
{
"id": "con_25",
"documentation": [
],
"any": [
],
"otherAttributes": {
},
"type": "{http://winery.opentosca.org/test/ponyuniverse}standsOn",
"sourceElement": {
"ref": "shetland_pony"
},
"targetElement": {
"ref": "straw"
},
"name": "con_25"
},
{
"id": "con_47",
"documentation": [
],
"any": [
],
"otherAttributes": {
},
"properties": {
"propertyType": "KV",
"kvproperties": {
"Driver": ""
}
},
"type": "{http://winery.opentosca.org/test/ponyuniverse}attendTo",
"sourceElement": {
"ref": "shetland_pony"
},
"targetElement": {
"ref": "ponycompetition"
},
"name": "con_47"
}
],
"nodeTemplates": [
{
"id": "shetland_pony",
Expand Down Expand Up @@ -82,8 +40,8 @@
"name": "shetland_pony",
"minInstances": 1,
"maxInstances": "1",
"x": "677",
"y": "161"
"y": "161",
"x": "677"
},
{
"id": "straw",
Expand All @@ -100,8 +58,8 @@
"name": "straw",
"minInstances": 1,
"maxInstances": "1",
"x": "677",
"y": "545"
"y": "545",
"x": "677"
},
{
"id": "ponycompetition",
Expand Down Expand Up @@ -148,8 +106,51 @@
"name": "ponycompetition",
"minInstances": 1,
"maxInstances": "1",
"x": "1237",
"y": "137"
"y": "137",
"x": "1237"
}
],
"relationshipTemplates": [
{
"id": "con_25",
"documentation": [
],
"any": [
],
"otherAttributes": {
},
"type": "{http://winery.opentosca.org/test/ponyuniverse}standsOn",
"sourceElement": {
"ref": "shetland_pony"
},
"targetElement": {
"ref": "straw"
},
"name": "con_25"
},
{
"id": "con_47",
"documentation": [
],
"any": [
],
"otherAttributes": {
},
"properties": {
"propertyType": "KV",
"namespace": "http://winery.opentosca.org/test/ponyuniverse/propertiesdefinition/winery",
"kvproperties": {
"Driver": ""
}
},
"type": "{http://winery.opentosca.org/test/ponyuniverse}attendTo",
"sourceElement": {
"ref": "shetland_pony"
},
"targetElement": {
"ref": "ponycompetition"
},
"name": "con_47"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,6 @@
],
"otherAttributes": {
},
"relationshipTemplates": [
{
"id": "con_47",
"documentation": [
],
"any": [
],
"otherAttributes": {
},
"properties": {
"propertyType": "KV",
"kvproperties": {
"Driver": ""
}
},
"type": "{http://winery.opentosca.org/test/ponyuniverse}attendTo",
"sourceElement": {
"ref": "shetland_pony"
},
"targetElement": {
"ref": "ponycompetition"
},
"name": "con_47"
}
],
"nodeTemplates": [
{
"id": "shetland_pony",
Expand Down Expand Up @@ -66,8 +41,8 @@
"name": "shetland_pony",
"minInstances": 1,
"maxInstances": "1",
"x": "677",
"y": "161"
"y": "161",
"x": "677"
},
{
"id": "ponycompetition",
Expand Down Expand Up @@ -114,8 +89,34 @@
"name": "ponycompetition",
"minInstances": 1,
"maxInstances": "1",
"x": "1237",
"y": "137"
"y": "137",
"x": "1237"
}
],
"relationshipTemplates": [
{
"id": "con_47",
"documentation": [
],
"any": [
],
"otherAttributes": {
},
"properties": {
"propertyType": "KV",
"namespace": "http://winery.opentosca.org/test/ponyuniverse/propertiesdefinition/winery",
"kvproperties": {
"Driver": ""
}
},
"type": "{http://winery.opentosca.org/test/ponyuniverse}attendTo",
"sourceElement": {
"ref": "shetland_pony"
},
"targetElement": {
"ref": "ponycompetition"
},
"name": "con_47"
}
]
},
Expand Down Expand Up @@ -190,8 +191,8 @@
"name": "dressageequipment",
"minInstances": 1,
"maxInstances": "1",
"x": "804",
"y": "270"
"y": "270",
"x": "804"
}
],
"relationshipTemplates": [
Expand Down
Loading

0 comments on commit fde6ef4

Please sign in to comment.