/** * @return */ private boolean isMigrating() { EJBJar jar = ((ContainerManagedEntity) getTarget()).getEjbJar(); if (jar != null) return EcoreUtil.getExistingAdapter(jar, J2EE_PROJ_MIGRATION_ADAPTER) != null; return false; }
/** * The key has been touched. * * @param Notification * msg - The notification message. */ protected void touchKeyShapeAdapter(Notification msg) { if (msg == null) return; ContainerManagedEntity cmp = (ContainerManagedEntity) getTarget(); JavaClass primaryKeyClass = cmp.getPrimaryKey(); //Synch the two lists. synchCMPandKeyAttributes(cmp, primaryKeyClass); } // touchKeyShapeAdapter
/** * The ejb class has been flushed. * * @param Notification * msg - The notification message. */ protected void touchBeanAdapter(Notification msg) { if (msg == null) return; ContainerManagedEntity cmp = (ContainerManagedEntity) getTarget(); List cmpAttributes = cmp.getPersistentAttributes(); if (cmpAttributes != null || !cmpAttributes.isEmpty()) { boolean modFlag = getCurrentModificationFlag(); try { for (int i = 0; i < cmpAttributes.size(); i++) { CMPAttribute cmpAttr = (CMPAttribute) cmpAttributes.get(i); if (cmpAttr != null && !cmpAttr.isDerived()) { cmpAttr.setEType(null); } } } finally { setModificationFlag(modFlag); } } synchCMPandKeyAttributes(cmp, cmp.getPrimaryKey()); }
/** * */ private void initializeTarget() { ContainerManagedEntity cmp = (ContainerManagedEntity) getTarget(); addAttributeMaintenanceAdapter(cmp.getEjbClass()); if (shouldAddToPrimaryKeyClass(cmp)) addAttributeMaintenanceAdapter(cmp.getPrimaryKey()); }
/** * Use if the there was an touch notification. * * @param Notification * msg - Message indicates what has changed. */ protected void jemFlushNotification(Notification msg) { if ((NotificationUtil.isFlushNewEvent(msg) || NotificationUtil.isFlushEvent(msg)) && !isMigrating()) { if (msg.getNotifier() == ((ContainerManagedEntity) getTarget()).getEjbClass()) { touchBeanAdapter(msg); } else if (msg.getNotifier() == ((ContainerManagedEntity) getTarget()).getPrimaryKey()) { touchKeyShapeAdapter(msg); } // if //if the notifier is eq the primary key //else ejb bean class flush } // if } // touchNotification
public void setTarget(Notifier newTarget) { boolean isChanged = getTarget() != newTarget; if (newTarget == null) { super.setTarget(newTarget); cmpResource = null; } else if (newTarget instanceof ContainerManagedEntity) { //TODO - uncomment when compile errors are gone if (false)/* (EJBCommandCopier.isCodegenCopy(newTarget)) */ newTarget.eAdapters().remove(this); else { Resource res = ((ContainerManagedEntity) newTarget).eResource(); if (res != null && res.getResourceSet() != null) { super.setTarget(newTarget); if (isChanged) initializeTarget(); } } } }
/** * Use if the there was an set notification. * * @param Notification * msg - Message indicates what has changed. */ protected void setNotification(Notification msg) { EStructuralFeature sf = (EStructuralFeature) msg.getFeature(); if (sf == EJB_PACK.getEnterpriseBean_EjbClass() || sf == EJB_PACK.getEntity_PrimaryKey()) { if (!isMigrating()) { removeAttributeMaintenanceAdapter((Notifier) msg.getOldValue()); addAttributeMaintenanceAdapter((Notifier) msg.getNewValue()); touchKeyShapeAdapter(msg); } } else if (sf == EJB_PACK.getEntity_PrimaryKey()) { removeAttributeMaintenanceAdapter((Notifier) msg.getOldValue()); if (shouldAddToPrimaryKeyClass((ContainerManagedEntity) getTarget())) addAttributeMaintenanceAdapter((Notifier) msg.getNewValue()); } else { jemFlushNotification(msg); //In EMF a TOUCH is a SET. } } // setNotification