* ONAP Policy Model
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.models.tosca.simple.concepts;
import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId;
private Status status = Status.SUPPORTED;
@ElementCollection
- private List<JpaToscaConstraint> constraints;
+ private List<JpaToscaConstraint> constraints = new ArrayList<>();
@Column
private JpaToscaEntrySchema entrySchema;
+ @ElementCollection
+ private Map<String, String> metadata = new LinkedHashMap<>();
+
/**
* The Default Constructor creates a {@link JpaToscaProperty} object with a null key.
*/
// Constraints are immutable
this.constraints = (copyConcept.constraints != null ? new ArrayList<>(copyConcept.constraints) : null);
this.entrySchema = (copyConcept.entrySchema != null ? new JpaToscaEntrySchema(copyConcept.entrySchema) : null);
+ this.metadata = (copyConcept.metadata != null ? new LinkedHashMap<>(copyConcept.metadata) : null);
}
/**
toscaProperty.setEntrySchema(entrySchema.toAuthorative());
}
+ if (metadata != null) {
+ toscaProperty.setMetadata(new LinkedHashMap<>(metadata));
+ }
+
return toscaProperty;
}
if (toscaProperty.getEntrySchema() != null) {
entrySchema = new JpaToscaEntrySchema(toscaProperty.getEntrySchema());
}
+
+ // Add the property metadata if it doesn't exist already
+ if (toscaProperty.getMetadata() != null) {
+ metadata = new LinkedHashMap<>(toscaProperty.getMetadata());
+ }
+
}
@Override
if (entrySchema != null) {
entrySchema.clean();
}
+
+ if (metadata != null) {
+ for (Entry<String, String> metadataEntry : metadata.entrySet()) {
+ metadataEntry.setValue(metadataEntry.getValue().trim());
+ }
+ }
}
@Override