summaryrefslogtreecommitdiffstats
path: root/model/basic-model/src
diff options
context:
space:
mode:
Diffstat (limited to 'model/basic-model/src')
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java56
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ModelService.java16
2 files changed, 45 insertions, 27 deletions
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java
index 693284dd0..375d7f0bf 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * 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.
@@ -119,7 +120,8 @@ public class DefaultApexDao implements ApexDao {
mg.getTransaction().begin();
mg.merge(obj);
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
@@ -137,7 +139,8 @@ public class DefaultApexDao implements ApexDao {
mg.getTransaction().begin();
mg.remove(mg.contains(obj) ? obj : mg.merge(obj));
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
@@ -156,7 +159,8 @@ public class DefaultApexDao implements ApexDao {
mg.createQuery(DELETE_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_NAME + key.getName()
+ AND_C_KEY_VERSION + key.getVersion() + "'", someClass).executeUpdate();
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
@@ -176,7 +180,8 @@ public class DefaultApexDao implements ApexDao {
+ key.getParentKeyName() + AND_C_KEY_PARENT_KEY_VERSION + key.getParentKeyVersion()
+ AND_C_KEY_LOCAL_NAME + key.getLocalName() + "'", someClass).executeUpdate();
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
@@ -196,7 +201,8 @@ public class DefaultApexDao implements ApexDao {
mg.merge(t);
}
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
@@ -216,7 +222,8 @@ public class DefaultApexDao implements ApexDao {
mg.remove(mg.contains(t) ? t : mg.merge(t));
}
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
@@ -241,7 +248,8 @@ public class DefaultApexDao implements ApexDao {
.executeUpdate();
}
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
return deletedCount;
@@ -266,7 +274,8 @@ public class DefaultApexDao implements ApexDao {
+ AND_C_KEY_LOCAL_NAME + key.getLocalName() + "'", someClass).executeUpdate();
}
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
return deletedCount;
@@ -282,7 +291,8 @@ public class DefaultApexDao implements ApexDao {
mg.getTransaction().begin();
mg.createQuery(DELETE_FROM + someClass.getSimpleName() + " c ", someClass).executeUpdate();
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
}
@@ -305,13 +315,14 @@ public class DefaultApexDao implements ApexDao {
t.copyTo(clonedT);
return clonedT;
} catch (final Exception e) {
- LOGGER.warn("Could not clone object of class \"" + someClass.getCanonicalName() + "\"", e);
+ LOGGER.warn("Could not clone object of class \"" + someClass.getName() + "\"", e);
return null;
}
} else {
return null;
}
- } finally {
+ }
+ finally {
mg.close();
}
}
@@ -333,13 +344,14 @@ public class DefaultApexDao implements ApexDao {
t.copyTo(clonedT);
return clonedT;
} catch (final Exception e) {
- LOGGER.warn("Could not clone object of class \"" + someClass.getCanonicalName() + "\"", e);
+ LOGGER.warn("Could not clone object of class \"" + someClass.getName() + "\"", e);
return null;
}
} else {
return null;
}
- } finally {
+ }
+ finally {
mg.close();
}
}
@@ -355,7 +367,8 @@ public class DefaultApexDao implements ApexDao {
final EntityManager mg = getEntityManager();
try {
return mg.createQuery(SELECT_C_FROM + someClass.getSimpleName() + " c", someClass).getResultList();
- } finally {
+ }
+ finally {
mg.close();
}
}
@@ -373,7 +386,8 @@ public class DefaultApexDao implements ApexDao {
return mg.createQuery(SELECT_C_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME
+ parentKey.getName() + AND_C_KEY_PARENT_KEY_VERSION + parentKey.getVersion() + "'",
someClass).getResultList();
- } finally {
+ }
+ finally {
mg.close();
}
}
@@ -391,7 +405,8 @@ public class DefaultApexDao implements ApexDao {
try {
ret = mg.createQuery(SELECT_C_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_NAME + key.getName()
+ AND_C_KEY_VERSION + key.getVersion() + "'", someClass).getResultList();
- } finally {
+ }
+ finally {
mg.close();
}
if (ret == null || ret.isEmpty()) {
@@ -418,7 +433,8 @@ public class DefaultApexDao implements ApexDao {
ret = mg.createQuery(SELECT_C_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME
+ key.getParentKeyName() + AND_C_KEY_PARENT_KEY_VERSION + key.getParentKeyVersion()
+ AND_C_KEY_LOCAL_NAME + key.getLocalName() + "'", someClass).getResultList();
- } finally {
+ }
+ finally {
mg.close();
}
if (ret == null || ret.isEmpty()) {
@@ -443,7 +459,8 @@ public class DefaultApexDao implements ApexDao {
ret = mg.merge(obj);
mg.flush();
mg.getTransaction().commit();
- } finally {
+ }
+ finally {
mg.close();
}
return ret;
@@ -462,7 +479,8 @@ public class DefaultApexDao implements ApexDao {
try {
size = mg.createQuery("SELECT COUNT(c) FROM " + someClass.getSimpleName() + " c", Long.class)
.getSingleResult();
- } finally {
+ }
+ finally {
mg.close();
}
return size;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ModelService.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ModelService.java
index 1e922b89a..251d92af5 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ModelService.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ModelService.java
@@ -1,19 +1,20 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -33,9 +34,9 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
* chains in modules such as the Apex engine and editor. The model service makes the model and concept definitions
* available statically.
*
- * <p>Note that the use of the model service means that only a single Apex model of a particular type may exist in
- * Apex (particularly the engine) at any time. Of course the model in a JVM can be changed at any time provided all
- * users of the model are stopped and restarted in an orderly manner.
+ * <p>Note that the use of the model service means that only a single Apex model of a particular type may exist in Apex
+ * (particularly the engine) at any time. Of course the model in a JVM can be changed at any time provided all users of
+ * the model are stopped and restarted in an orderly manner.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@@ -82,8 +83,7 @@ public abstract class ModelService {
final M model = (M) modelMap.get(modelClass);
if (model == null) {
- throw new ApexRuntimeException(
- "Model for " + modelClass.getCanonicalName() + " not found in model service");
+ throw new ApexRuntimeException("Model for " + modelClass.getName() + " not found in model service");
}
return model;