use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class TblSamlAssertionJpaController method edit.
public void edit(TblSamlAssertion tblSamlAssertion) throws NonexistentEntityException, ASDataException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblSamlAssertion persistentTblSamlAssertion = em.find(TblSamlAssertion.class, tblSamlAssertion.getId());
TblHosts hostIdOld = persistentTblSamlAssertion.getHostId();
TblHosts hostIdNew = tblSamlAssertion.getHostId();
if (hostIdNew != null) {
hostIdNew = em.getReference(hostIdNew.getClass(), hostIdNew.getId());
tblSamlAssertion.setHostId(hostIdNew);
}
tblSamlAssertion = em.merge(tblSamlAssertion);
if (hostIdOld != null && !hostIdOld.equals(hostIdNew)) {
hostIdOld.getTblSamlAssertionCollection().remove(tblSamlAssertion);
hostIdOld = em.merge(hostIdOld);
}
if (hostIdNew != null && !hostIdNew.equals(hostIdOld)) {
hostIdNew.getTblSamlAssertionCollection().add(tblSamlAssertion);
em.merge(hostIdNew);
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblSamlAssertion.getId();
if (findTblSamlAssertion(id) == null) {
throw new NonexistentEntityException("The tblSamlAssertion with id " + id + " no longer exists.");
}
}
throw new ASDataException(ex);
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class MwMleSourceJpaController method edit.
public void edit(MwMleSource mwMleSource) throws NonexistentEntityException, Exception {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
MwMleSource persistentMwMleSource = em.find(MwMleSource.class, mwMleSource.getId());
TblMle mleIdOld = persistentMwMleSource.getMleId();
TblMle mleIdNew = mwMleSource.getMleId();
if (mleIdNew != null) {
mleIdNew = em.getReference(mleIdNew.getClass(), mleIdNew.getId());
mwMleSource.setMleId(mleIdNew);
}
mwMleSource = em.merge(mwMleSource);
if (mleIdOld != null && !mleIdOld.equals(mleIdNew)) {
mleIdOld.getMwMleSourceCollection().remove(mwMleSource);
mleIdOld = em.merge(mleIdOld);
}
if (mleIdNew != null && !mleIdNew.equals(mleIdOld)) {
mleIdNew.getMwMleSourceCollection().add(mwMleSource);
em.merge(mleIdNew);
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = mwMleSource.getId();
if (findMwMleSource(id) == null) {
throw new NonexistentEntityException("The mwMleSource with id " + id + " no longer exists.");
}
}
throw ex;
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class TblEventTypeJpaController method destroy.
public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblEventType tblEventType;
try {
tblEventType = em.getReference(TblEventType.class, id);
tblEventType.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The tblEventType with id " + id + " no longer exists.", enfe);
}
List<String> illegalOrphanMessages = null;
Collection<TblModuleManifest> tblModuleManifestCollectionOrphanCheck = tblEventType.getTblModuleManifestCollection();
for (TblModuleManifest tblModuleManifestCollectionOrphanCheckTblModuleManifest : tblModuleManifestCollectionOrphanCheck) {
if (illegalOrphanMessages == null) {
illegalOrphanMessages = new ArrayList<String>();
}
illegalOrphanMessages.add("This TblEventType (" + tblEventType + ") cannot be destroyed since the TblModuleManifest " + tblModuleManifestCollectionOrphanCheckTblModuleManifest + " in its tblModuleManifestCollection field has a non-nullable eventID field.");
}
if (illegalOrphanMessages != null) {
throw new IllegalOrphanException(illegalOrphanMessages);
}
em.remove(tblEventType);
em.getTransaction().commit();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class TblEventTypeJpaController method edit.
public void edit(TblEventType tblEventType) throws IllegalOrphanException, NonexistentEntityException, ASDataException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblEventType persistentTblEventType = em.find(TblEventType.class, tblEventType.getId());
Collection<TblModuleManifest> tblModuleManifestCollectionOld = persistentTblEventType.getTblModuleManifestCollection();
Collection<TblModuleManifest> tblModuleManifestCollectionNew = tblEventType.getTblModuleManifestCollection();
List<String> illegalOrphanMessages = null;
for (TblModuleManifest tblModuleManifestCollectionOldTblModuleManifest : tblModuleManifestCollectionOld) {
if (!tblModuleManifestCollectionNew.contains(tblModuleManifestCollectionOldTblModuleManifest)) {
if (illegalOrphanMessages == null) {
illegalOrphanMessages = new ArrayList<String>();
}
illegalOrphanMessages.add("You must retain TblModuleManifest " + tblModuleManifestCollectionOldTblModuleManifest + " since its eventID field is not nullable.");
}
}
if (illegalOrphanMessages != null) {
throw new IllegalOrphanException(illegalOrphanMessages);
}
Collection<TblModuleManifest> attachedTblModuleManifestCollectionNew = new ArrayList<TblModuleManifest>();
for (TblModuleManifest tblModuleManifestCollectionNewTblModuleManifestToAttach : tblModuleManifestCollectionNew) {
tblModuleManifestCollectionNewTblModuleManifestToAttach = em.getReference(tblModuleManifestCollectionNewTblModuleManifestToAttach.getClass(), tblModuleManifestCollectionNewTblModuleManifestToAttach.getId());
attachedTblModuleManifestCollectionNew.add(tblModuleManifestCollectionNewTblModuleManifestToAttach);
}
tblModuleManifestCollectionNew = attachedTblModuleManifestCollectionNew;
tblEventType.setTblModuleManifestCollection(tblModuleManifestCollectionNew);
tblEventType = em.merge(tblEventType);
for (TblModuleManifest tblModuleManifestCollectionNewTblModuleManifest : tblModuleManifestCollectionNew) {
if (!tblModuleManifestCollectionOld.contains(tblModuleManifestCollectionNewTblModuleManifest)) {
TblEventType oldEventIDOfTblModuleManifestCollectionNewTblModuleManifest = tblModuleManifestCollectionNewTblModuleManifest.getEventID();
tblModuleManifestCollectionNewTblModuleManifest.setEventID(tblEventType);
tblModuleManifestCollectionNewTblModuleManifest = em.merge(tblModuleManifestCollectionNewTblModuleManifest);
if (oldEventIDOfTblModuleManifestCollectionNewTblModuleManifest != null && !oldEventIDOfTblModuleManifestCollectionNewTblModuleManifest.equals(tblEventType)) {
oldEventIDOfTblModuleManifestCollectionNewTblModuleManifest.getTblModuleManifestCollection().remove(tblModuleManifestCollectionNewTblModuleManifest);
em.merge(oldEventIDOfTblModuleManifestCollectionNewTblModuleManifest);
}
}
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblEventType.getId();
if (findTblEventType(id) == null) {
throw new NonexistentEntityException("The tblEventType with id " + id + " no longer exists.");
}
}
throw new ASDataException(ex);
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class TblHostSpecificManifestJpaController method edit.
public void edit(TblHostSpecificManifest tblHostSpecificManifest) throws NonexistentEntityException, ASDataException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblHostSpecificManifest persistentTblHostSpecificManifest = em.find(TblHostSpecificManifest.class, tblHostSpecificManifest.getId());
TblModuleManifest moduleManifestIDOld = persistentTblHostSpecificManifest.getModuleManifestID();
TblModuleManifest moduleManifestIDNew = tblHostSpecificManifest.getModuleManifestID();
if (moduleManifestIDNew != null) {
moduleManifestIDNew = em.getReference(moduleManifestIDNew.getClass(), moduleManifestIDNew.getId());
tblHostSpecificManifest.setModuleManifestID(moduleManifestIDNew);
}
tblHostSpecificManifest = em.merge(tblHostSpecificManifest);
if (moduleManifestIDOld != null && !moduleManifestIDOld.equals(moduleManifestIDNew)) {
moduleManifestIDOld.getTblHostSpecificManifestCollection().remove(tblHostSpecificManifest);
moduleManifestIDOld = em.merge(moduleManifestIDOld);
}
if (moduleManifestIDNew != null && !moduleManifestIDNew.equals(moduleManifestIDOld)) {
moduleManifestIDNew.getTblHostSpecificManifestCollection().add(tblHostSpecificManifest);
em.merge(moduleManifestIDNew);
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblHostSpecificManifest.getId();
if (findTblHostSpecificManifest(id) == null) {
throw new NonexistentEntityException("The tblHostSpecificManifest with id " + id + " no longer exists.");
}
}
throw new ASDataException(ex);
} finally {
em.close();
}
}
Aggregations