Code Review
/
policy
/
engine.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fixed the sonar issues in ONAP-REST.
[policy/engine.git]
/
ONAP-REST
/
src
/
main
/
java
/
org
/
onap
/
policy
/
rest
/
util
/
MSModelUtils.java
diff --git
a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
index
3880b35
..
18fd80c
100644
(file)
--- a/
ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
+++ b/
ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
@@
-2,7
+2,7
@@
* ============LICENSE_START=======================================================
* ONAP-REST
* ================================================================================
* ============LICENSE_START=======================================================
* ONAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017
-2018
AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-102,7
+102,7
@@
public class MSModelUtils {
// Pulling out dependency from file
while (treeItr.hasNext()) {
// Pulling out dependency from file
while (treeItr.hasNext()) {
- EObject obj =
(EObject)
treeItr.next();
+ EObject obj = treeItr.next();
if (obj instanceof EClassifier) {
EClassifier eClassifier = (EClassifier) obj;
className = eClassifier.getName();
if (obj instanceof EClassifier) {
EClassifier eClassifier = (EClassifier) obj;
className = eClassifier.getName();
@@
-184,9
+184,7
@@
public class MSModelUtils {
logger.error("Error loading Encore Resource for new Model" + e);
}
logger.error("Error loading Encore Resource for new Model" + e);
}
- EPackage root = (EPackage) resource.getContents().get(0);
-
- return root;
+ return (EPackage) resource.getContents().get(0);
}
private HashMap<String, String> getEEnum(EObject obj) {
}
private HashMap<String, String> getEEnum(EObject obj) {
@@
-315,7
+313,11
@@
public class MSModelUtils {
if (annotation && obj instanceof EReference) {
EClass refType = ((EReference) obj).getEReferenceType();
if(!refType.toString().contains(eProxyURI)){
if (annotation && obj instanceof EReference) {
EClass refType = ((EReference) obj).getEReferenceType();
if(!refType.toString().contains(eProxyURI)){
- subAttribute.put(eStrucClassifier.getName(), refType.getName());
+ String required = ":required-false";
+ if(eStrucClassifier.getLowerBound() == 1){
+ required = ":required-true";
+ }
+ subAttribute.put(eStrucClassifier.getName(), refType.getName() + required);
}
}
}
}
}
}
@@
-348,10
+350,7
@@
public class MSModelUtils {
public JSONObject buildJavaObject(Map<String, String> map){
public JSONObject buildJavaObject(Map<String, String> map){
- JSONObject returnValue = new JSONObject(map);
-
- return returnValue;
-
+ return new JSONObject(map);
}
public Map<String, String> getRefAttributeList(EPackage root, String className, String superClass){
}
public Map<String, String> getRefAttributeList(EPackage root, String className, String superClass){
@@
-390,18
+389,28
@@
public class MSModelUtils {
refAttribute.put(eStrucClassifier.getName(), refValue);
} else {
String array = arrayCheck(((EStructuralFeature) obj).getUpperBound());
refAttribute.put(eStrucClassifier.getName(), refValue);
} else {
String array = arrayCheck(((EStructuralFeature) obj).getUpperBound());
- refAttribute.put(eStrucClassifier.getName(), refType.getName() + array);
+ String required = ":required-false";
+ if(((EStructuralFeature) obj).getLowerBound() == 1){
+ required = ":required-true";
+ }
+ refAttribute.put(eStrucClassifier.getName(), refType.getName() + array + required);
}
} else if (annotation && obj instanceof EAttributeImpl){
EClassifier refType = ((EAttributeImpl) obj).getEType();
if (refType instanceof EEnumImpl){
String array = arrayCheck(((EStructuralFeature) obj).getUpperBound());
}
} else if (annotation && obj instanceof EAttributeImpl){
EClassifier refType = ((EAttributeImpl) obj).getEType();
if (refType instanceof EEnumImpl){
String array = arrayCheck(((EStructuralFeature) obj).getUpperBound());
- refAttribute.put(eStrucClassifier.getName(), refType.getName() + array); }
+ String required = ":required-false";
+ if(((EStructuralFeature) obj).getLowerBound() == 1){
+ required = ":required-true";
+ }
+ refAttribute.put(eStrucClassifier.getName(), refType.getName() + array + required);
+ }
}
}
}
}
}
}
}
}
}
}
+
return refAttribute;
}
return refAttribute;
}
@@
-637,9
+646,7
@@
public class MSModelUtils {
}
Gson gson = new Gson();
}
Gson gson = new Gson();
- String json = gson.toJson(myObject);
-
- return json;
+ return gson.toJson(myObject);
}
public Map<String, String> getRefclass(Map<String, MSAttributeObject> classMap, String className){
}
public Map<String, String> getRefclass(Map<String, MSAttributeObject> classMap, String className){
@@
-673,8
+680,7
@@
public class MSModelUtils {
}
}
}
}
- String returnValue = createJson(workingMap, classMap, modelName);
- return returnValue;
+ return createJson(workingMap, classMap, modelName);
}
public List<String> getFullDependencyList(List<String> dependency, Map<String,MSAttributeObject > classMap) {
}
public List<String> getFullDependencyList(List<String> dependency, Map<String,MSAttributeObject > classMap) {