* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2019 European Software Marketing Ltd.
+ * Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2017-2019 European Software Marketing Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Set;
import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
-import org.onap.aai.babel.xml.generator.error.IllegalAccessException;
-import org.onap.aai.babel.xml.generator.model.Widget.Type;
-import org.onap.aai.babel.xml.generator.types.ModelType;
public abstract class Model {
public abstract void populate(Model model, String value);
}
- private String modelId;
+ private String modelId; // model-invariant-id
private String modelName;
- private String modelNameVersionId;
+ private String modelNameVersionId; // model-version-id
private String modelVersion;
private String modelDescription;
*/
public static Resource getModelFor(String toscaType, String metaDataType) {
if ("Configuration".equals(metaDataType)) {
- return new Resource(Type.CONFIGURATION, true);
+ return new Resource(WidgetType.valueOf("CONFIGURATION"), true);
} else if ("CR".equals(metaDataType)) {
- return new Resource(Type.CR, true);
+ return new Resource(WidgetType.valueOf("CR"), true);
} else {
return getModelFor(toscaType);
}
}
- public abstract boolean addResource(Resource resource);
-
public abstract boolean addWidget(Widget resource) throws XmlArtifactGenerationException;
- public abstract Widget.Type getWidgetType();
+ /**
+ * @return the Widget Type of this model.
+ */
+ public abstract WidgetType getWidgetType();
- public abstract Map<String, Object> getProperties();
+ public abstract String getModelTypeName();
- public abstract boolean isResource();
+ /**
+ * Check whether the model's Widget Type matches the supplied type.
+ *
+ * @param type
+ * the Widget Type to compare
+ * @return true if the Widget Type of this model matches the supplied type
+ */
+ public boolean hasWidgetType(String type) {
+ return getWidgetType() == WidgetType.valueOf(type);
+ }
+
+ public boolean addResource(Resource resource) {
+ return resources.add(resource);
+ }
/**
* Gets delete flag.
}
public String getModelId() {
- checkSupported();
return modelId;
}
}
public String getModelNameVersionId() {
- checkSupported();
return modelNameVersionId;
}
- /**
- * Gets model type.
- *
- * @return the model type
- */
- public ModelType getModelType() {
- if (this instanceof Service) {
- return ModelType.SERVICE;
- } else if (this instanceof Resource) {
- return ModelType.RESOURCE;
- } else if (this instanceof Widget) {
- return ModelType.WIDGET;
- } else {
- return null;
- }
- }
-
/**
* Gets widget version id.
*
* the model ident info
*/
public void populateModelIdentificationInformation(Map<String, String> modelIdentInfo) {
+ if (modelIdentInfo == null) {
+ return;
+ }
Iterator<String> iter = modelIdentInfo.keySet().iterator();
String property;
while (iter.hasNext()) {
return widgets;
}
- private void checkSupported() {
- if (this instanceof Widget) {
- throw new IllegalAccessException(GENERATOR_AAI_ERROR_UNSUPPORTED_WIDGET_OPERATION);
- }
+ @Override
+ public String toString() {
+ return "Model [type=" + getModelTypeName() + ", name=" + getModelName() + "]";
}
}