* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
import org.onap.policy.rest.jpa.MicroServiceModels;
import org.onap.policy.rest.jpa.UserInfo;
-import org.onap.policy.rest.util.MSAttributeObject;
-import org.onap.policy.rest.util.MSModelUtils;
-import org.onap.policy.rest.util.MSModelUtils.MODEL_TYPE;
+import org.onap.policy.rest.util.MsAttributeObject;
+import org.onap.policy.rest.util.MsModelUtils;
+import org.onap.policy.rest.util.MsModelUtils.ModelType;
public class CreateNewMicroServiceModel {
private static final Logger logger = FlexLogger.getLogger(CreateNewMicroServiceModel.class);
private MicroServiceModels newModel = null;
- private HashMap<String, MSAttributeObject> classMap = new HashMap<>();
+ private HashMap<String, MsAttributeObject> classMap = new HashMap<>();
- private MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
+ private MsModelUtils utils = new MsModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
public CreateNewMicroServiceModel(String fileName, String serviceName, String string, String version) {
super();
this.newModel.setUserCreatedBy(userInfo);
String cleanUpFile = null;
- Map<String, MSAttributeObject> tempMap = new HashMap<>();
+ Map<String, MsAttributeObject> tempMap = new HashMap<>();
// Need to delete the file
if (importFile.contains(".zip")) {
extractFolder(randomID + ".zip");
cleanUpFile = "ExtractDir" + File.separator + randomID + ".yml";
} else {
- tempMap = utils.processEpackage("ExtractDir" + File.separator + randomID + ".xmi", MODEL_TYPE.XMI);
+ tempMap = utils.processEpackage("ExtractDir" + File.separator + randomID + ".xmi", ModelType.XMI);
classMap.putAll(tempMap);
cleanUpFile = "ExtractDir" + File.separator + randomID + ".xmi";
}
}
private void processFiles(String modelName, List<File> fileList) {
- Map<String, MSAttributeObject> tempMap;
+ Map<String, MsAttributeObject> tempMap;
for (File file : fileList) {
if (file.isFile()) {
int indx = file.getName().lastIndexOf('.');
} else {
- tempMap = utils.processEpackage(file.getAbsolutePath(), MODEL_TYPE.XMI);
+ tempMap = utils.processEpackage(file.getAbsolutePath(), ModelType.XMI);
classMap.putAll(tempMap);
}
}
utils.parseTosca(fileName);
- MSAttributeObject msAttributes = new MSAttributeObject();
+ MsAttributeObject msAttributes = new MsAttributeObject();
msAttributes.setClassName(modelName);
LinkedHashMap<String, String> returnAttributeList = new LinkedHashMap<>();
returnReferenceList.put(modelName, utils.getReferenceAttributes());
msAttributes.setRefAttribute(returnReferenceList);
- if (!PolicyDBDao.isNullOrEmpty(utils.getListConstraints())) {
+ if (!PolicyDbDao.isNullOrEmpty(utils.getListConstraints())) {
LinkedHashMap<String, String> enumList = new LinkedHashMap<>();
String[] listArray = utils.getListConstraints().split("#");
for (String str : listArray) {
public Map<String, String> addValuesToNewModel(String type) {
Map<String, String> successMap = new HashMap<>();
- MSAttributeObject mainClass = null;
+ MsAttributeObject mainClass = null;
List<String> dependency = null;
String subAttribute = null;
newModel.setDependency("[]");
if (mainClass.getSubClass() != null) {
String value = new Gson().toJson(mainClass.getSubClass());
- newModel.setSub_attributes(value);
+ newModel.setSubAttributes(value);
}
if (mainClass.getAttribute() != null) {
String refAttributes = mainClass.getRefAttribute().toString().replace("{", "").replace("}", "");
int equalsIndex = refAttributes.indexOf("=");
String refAttributesAfterFirstEquals = refAttributes.substring(equalsIndex + 1);
- this.newModel.setRef_attributes(refAttributesAfterFirstEquals);
+ this.newModel.setRefAttributes(refAttributesAfterFirstEquals);
}
if (mainClass.getEnumType() != null) {
dependency = utils.getFullDependencyList(dependency, classMap);
if (!dependency.isEmpty()) {
for (String element : dependency) {
- MSAttributeObject temp = new MSAttributeObject();
+ MsAttributeObject temp = new MsAttributeObject();
if (classMap.containsKey(element)) {
temp = classMap.get(element);
mainClass.addAllRefAttribute(temp.getRefAttribute());
}
subAttribute = utils.createSubAttributes(dependency, classMap, this.newModel.getModelName());
- this.newModel.setSub_attributes(subAttribute);
+ this.newModel.setSubAttributes(subAttribute);
if (mainClass.getAttribute() != null && !mainClass.getAttribute().isEmpty()) {
this.newModel.setAttributes(mainClass.getAttribute().toString().replace("{", "").replace("}", ""));
}
if (mainClass.getRefAttribute() != null && !mainClass.getRefAttribute().isEmpty()) {
this.newModel
- .setRef_attributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""));
+ .setRefAttributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""));
}
if (mainClass.getEnumType() != null && !mainClass.getEnumType().isEmpty()) {
model.setDependency(this.newModel.getDependency());
model.setDescription(this.newModel.getDescription());
model.setEnumValues(this.newModel.getEnumValues());
- model.setRef_attributes(this.newModel.getRef_attributes());
- model.setSub_attributes(this.newModel.getSub_attributes());
+ model.setRefAttributes(this.newModel.getRefAttributes());
+ model.setSubAttributes(this.newModel.getSubAttributes());
model.setDataOrderInfo(this.newModel.getDataOrderInfo());
model.setDecisionModel(this.newModel.isDecisionModel());
model.setRuleFormation(this.newModel.getRuleFormation());