- if (toscaDataType.getConstraints() != null) {
- constraints = new ArrayList<>();
-
- for (ToscaConstraint toscaConstraint: toscaDataType.getConstraints()) {
- constraints.add(JpaToscaConstraint.newInstance(toscaConstraint));
- }
- }
-
- if (toscaDataType.getProperties() != null) {
- properties = new LinkedHashMap<>();
- for (Entry<String, ToscaProperty> toscaPropertyEntry : toscaDataType.getProperties().entrySet()) {
- JpaToscaProperty jpaProperty = new JpaToscaProperty(toscaPropertyEntry.getValue());
- jpaProperty.setKey(new PfReferenceKey(getKey(), toscaPropertyEntry.getKey()));
- properties.put(toscaPropertyEntry.getKey(), jpaProperty);
- }
- }
- }
-
- @Override
- public List<PfKey> getKeys() {
- final List<PfKey> keyList = super.getKeys();
-
- if (properties != null) {
- for (JpaToscaProperty property : properties.values()) {
- keyList.addAll(property.getKeys());
- }
- }
-
- return keyList;
- }
-
- @Override
- public void clean() {
- super.clean();
-
- if (properties != null) {
- for (JpaToscaProperty property : properties.values()) {
- property.clean();
- }
- }
- }
-
- @Override
- public PfValidationResult validate(final PfValidationResult resultIn) {
- PfValidationResult result = super.validate(resultIn);
-
- if (constraints != null) {
- result = validateConstraints(result);
- }
-
- if (properties != null) {
- result = validateProperties(result);
- }
-
- return result;
- }
-
- /**
- * Validate the constraints.
- *
- * @param result The result of validations up to now
- * @return the validation result
- */
- private PfValidationResult validateConstraints(@NonNull final PfValidationResult resultIn) {
- PfValidationResult result = resultIn;
-
- for (JpaToscaConstraint constraint : constraints) {
- if (constraint == null) {
- result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
- "data type constraint may not be null "));
- }
- }
- return result;
- }
-
- /**
- * Validate the properties.
- *
- * @param result The result of validations up to now
- * @return the validation result
- */
- private PfValidationResult validateProperties(final PfValidationResult resultIn) {
- PfValidationResult result = resultIn;
-
- for (JpaToscaProperty property : properties.values()) {
- if (property == null) {
- result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
- "data type property may not be null "));
- } else {
- result = property.validate(result);
- }
- }
- return result;