public static void batchRelateAll( ModelRoot modelRoot, boolean notifyChanges, boolean searchAllRoots, boolean relateProxies) { InstanceList instances = modelRoot.getInstanceList(InstanceStateMachine_c.class); synchronized (instances) { Iterator<NonRootModelElement> cursor = instances.iterator(); while (cursor.hasNext()) { final InstanceStateMachine_c inst = (InstanceStateMachine_c) cursor.next(); inst.batchRelate(modelRoot, relateProxies, notifyChanges, searchAllRoots); } } }
private static InstanceStateMachine_c findInstanceStateMachineInstance( ModelRoot modelRoot, ClassQueryInterface_c test, boolean loadComponent) { InstanceList instances = modelRoot.getInstanceList(InstanceStateMachine_c.class); synchronized (instances) { for (int i = 0; i < instances.size(); ++i) { InstanceStateMachine_c x = (InstanceStateMachine_c) instances.get(i); if (test == null || test.evaluate(x)) { if (x.ensureLoaded(loadComponent)) return x; } } } return null; }
public static InstanceStateMachine_c resolveInstance( ModelRoot modelRoot, java.util.UUID p_m_sm_id, java.util.UUID p_m_obj_id) { InstanceList instances = modelRoot.getInstanceList(InstanceStateMachine_c.class); InstanceStateMachine_c source = null; synchronized (instances) { Object[] key = {p_m_sm_id}; source = (InstanceStateMachine_c) instances.get(key); if (source != null && !modelRoot.isCompareRoot()) { source.convertFromProxy(); source.batchUnrelate(); // pre-process the uuid so that we re-use null uuid instance rather then creating a new one. source.m_sm_id = IdAssigner.preprocessUUID(p_m_sm_id); // pre-process the uuid so that we re-use null uuid instance rather then creating a new one. source.m_obj_id = IdAssigner.preprocessUUID(p_m_obj_id); return source; } } // there is no instance matching the id InstanceStateMachine_c new_inst = new InstanceStateMachine_c(modelRoot, p_m_sm_id, p_m_obj_id); return new_inst; }
public static InstanceStateMachine_c[] InstanceStateMachineInstances( ModelRoot modelRoot, ClassQueryInterface_c test, boolean loadComponent) { if (loadComponent) { PersistenceManager.ensureAllInstancesLoaded(modelRoot, InstanceStateMachine_c.class); } InstanceList instances = modelRoot.getInstanceList(InstanceStateMachine_c.class); Vector matches = new Vector(); synchronized (instances) { for (int i = 0; i < instances.size(); ++i) { InstanceStateMachine_c x = (InstanceStateMachine_c) instances.get(i); if (test == null || test.evaluate(x)) { if (x.ensureLoaded(loadComponent)) matches.add(x); } } if (matches.size() > 0) { InstanceStateMachine_c[] ret_set = new InstanceStateMachine_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new InstanceStateMachine_c[0]; } } }
// end declare accessors public static void checkClassConsistency(ModelRoot modelRoot) { Ooaofooa.log.println( ILogger.OPERATION, "Instance State Machine", //$NON-NLS-1$ " Operation entered: Instance State Machine::checkClassConsistency"); //$NON-NLS-1$ if (Boolean.valueOf(System.getenv("PTC_MCC_ENABLED")) == false) { // $NON-NLS-1$ return; } InstanceStateMachine_c[] objs = InstanceStateMachine_c.InstanceStateMachineInstances(modelRoot, null, false); for (int i = 0; i < objs.length; i++) { objs[i].checkConsistency(); } }
public static InstanceStateMachine_c InstanceStateMachineInstance( ModelRoot modelRoot, ClassQueryInterface_c test, boolean loadComponent) { InstanceStateMachine_c result = findInstanceStateMachineInstance(modelRoot, test, loadComponent); if (result == null && loadComponent) { List pmcs = PersistenceManager.findAllComponents(modelRoot, InstanceStateMachine_c.class); for (int i = 0; i < pmcs.size(); i++) { PersistableModelComponent component = (PersistableModelComponent) pmcs.get(i); if (!component.isLoaded()) { try { component.load(new NullProgressMonitor()); result = findInstanceStateMachineInstance(modelRoot, test, loadComponent); if (result != null) return result; } catch (Exception e) { CorePlugin.logError("Error Loading component", e); } } } } if (result != null && loadComponent) { result.loadProxy(); } return result; }
public static InstanceStateMachine_c createProxy( ModelRoot modelRoot, java.util.UUID p_m_sm_id, java.util.UUID p_m_obj_id, String p_contentPath, IPath p_localPath) { ModelRoot resolvedModelRoot = ModelRoot.findModelRoot(modelRoot, p_contentPath, p_localPath); // if a model root was not resolved it is most likely // due to a missing file of the proxy, defualt back to // the original model root if (resolvedModelRoot != null) modelRoot = resolvedModelRoot; InstanceList instances = modelRoot.getInstanceList(InstanceStateMachine_c.class); InstanceStateMachine_c new_inst = null; synchronized (instances) { Object[] key = {p_m_sm_id}; new_inst = (InstanceStateMachine_c) instances.get(key); } String contentPath = PersistenceUtil.resolveRelativePath(p_localPath, new Path(p_contentPath)); if (modelRoot.isNewCompareRoot()) { // for comparisons we do not want to change // the content path contentPath = p_contentPath; } if (new_inst != null && !modelRoot.isCompareRoot()) { PersistableModelComponent pmc = new_inst.getPersistableComponent(); if (pmc == null) { // dangling reference, redo this instance new_inst.batchUnrelate(); // pre-process the uuid so that we re-use null uuid instance rather then creating a new one. new_inst.m_sm_id = IdAssigner.preprocessUUID(p_m_sm_id); // pre-process the uuid so that we re-use null uuid instance rather then creating a new one. new_inst.m_obj_id = IdAssigner.preprocessUUID(p_m_obj_id); } } if (new_inst == null) { // there is no instance matching the id, create a proxy // if the resource doesn't exist then this will be a dangling reference new_inst = new InstanceStateMachine_c(modelRoot, p_m_sm_id, p_m_obj_id); new_inst.m_contentPath = contentPath; new_inst.setComponent(null); } return new_inst; }
public boolean performFinish() { TransactionUtil.TransactionGroup transactionGroup = null; ModelRoot modelRoot = v_asyncMessage.getModelRoot(); try { transactionGroup = TransactionUtil.startTransactionsOnSelectedModelRoots( "Instance Event Formalize"); //$NON-NLS-1$ Message_c v_message = Message_c.getOneMSG_MOnR1018(v_asyncMessage); InteractionParticipant_c v_participant = InteractionParticipant_c.getOneSQ_POnR1007(v_message); Lifespan_c v_ls = Lifespan_c.getOneSQ_LSOnR930(v_participant); ClassInstanceParticipant_c v_cip = ClassInstanceParticipant_c.getOneSQ_CIPOnR930( InteractionParticipant_c.getOneSQ_POnR940(v_ls)); ModelClass_c v_cipclass = (ModelClass_c) modelRoot.getInstanceList(ModelClass_c.class).getGlobal(null, Gd_c.Null_unique_id()); if (((v_cip != null))) { v_cipclass = ModelClass_c.getOneO_OBJOnR934(v_cip); } else { v_cip = ClassInstanceParticipant_c.getOneSQ_CIPOnR930( InteractionParticipant_c.getOneSQ_POnR1007(v_message)); if (((v_cip != null))) { Communication_c v_communication = Communication_c.getOneCOMM_COMMOnR1126( ParticipantInCommunication_c.getOneCOMM_PICOnR1126( InteractionParticipant_c.getOneSQ_POnR930(v_cip))); if (((v_communication != null))) { v_cipclass = ModelClass_c.getOneO_OBJOnR934(v_cip); } } } if (((v_cipclass != null))) { StateMachineEvent_c v_evt = StateMachineEvent_c.getOneSM_EVTOnR1009( EventMessage_c.getOneMSG_EOnR1019(v_asyncMessage)); java.util.UUID v_existingId = Gd_c.Null_unique_id(); if (((v_evt != null))) { v_existingId = v_evt.getSmevt_id(); } StateMachine_c v_stateMachine = StateMachine_c.getOneSM_SMOnR517(InstanceStateMachine_c.getOneSM_ISMOnR518(v_cipclass)); StateMachine_c[] v_machines = StateMachine_c.getManySM_SMsOnR517( InstanceStateMachine_c.getManySM_ISMsOnR518( ModelClass_c.getManyO_OBJsOnR8001( PackageableElement_c.getManyPE_PEsOnR8000( Package_c.getManyEP_PKGsOnR1405( SystemModel_c.getManyS_SYSsOnR1405( Package_c.getManyEP_PKGsOnR8000( PackageableElement_c.getManyPE_PEsOnR8001( v_cipclass)))))))); if (((v_machines.length == 0))) { v_machines = StateMachine_c.getManySM_SMsOnR517( InstanceStateMachine_c.getManySM_ISMsOnR518( ModelClass_c.getManyO_OBJsOnR2( Subsystem_c.getManyS_SSsOnR1( Domain_c.getManyS_DOMsOnR1( Subsystem_c.getManyS_SSsOnR2(v_cipclass)))))); } if (((v_Message != null))) { if (v_asyncMessage != null) { v_asyncMessage.Formalizewithevent(v_Message.getSmevt_id()); } else { Throwable t = new Throwable(); t.fillInStackTrace(); CorePlugin.logError("Attempted to call an operation on a null instance.", t); } } } // catch all exceptions and cancel the transaction } catch (Exception e) { if (transactionGroup != null) TransactionUtil.cancelTransactions(transactionGroup, e); CorePlugin.logError("Transaction: Instance Event Formalize failed", e); // $NON-NLS-1$ // return true so that the wizard will // close return true; } if (transactionGroup != null) TransactionUtil.endTransactions(transactionGroup); if (m_viewer != null) { if (m_viewer instanceof StructuredViewer) { ((StructuredViewer) m_viewer).refresh(v_asyncMessage); } else { m_viewer.refresh(); } } return true; }
public boolean checkConsistency() { Ooaofooa.log.println( ILogger.OPERATION, "Instance State Machine", //$NON-NLS-1$ " Operation entered: Instance State Machine::checkConsistency"); //$NON-NLS-1$ if (Boolean.valueOf(System.getenv("PTC_MCC_ENABLED")) == false) { // $NON-NLS-1$ return true; } ModelRoot modelRoot = getModelRoot(); boolean retval = true; class InstanceStateMachine_c_test39208_c implements ClassQueryInterface_c { InstanceStateMachine_c_test39208_c(java.util.UUID p39209) { m_p39209 = p39209; } private java.util.UUID m_p39209; public boolean evaluate(Object candidate) { InstanceStateMachine_c selected = (InstanceStateMachine_c) candidate; boolean retval = false; retval = (selected.getSm_id().equals(m_p39209)); return retval; } } InstanceStateMachine_c[] objs39207 = InstanceStateMachine_c.InstanceStateMachineInstances( modelRoot, new InstanceStateMachine_c_test39208_c(getSm_id())); if (((objs39207.length) == 0)) { if (CorePlugin.getDefault().isDebugging()) { Ooaofooa.log.println( ILogger.CONSISTENCY, "Instance State Machine", //$NON-NLS-1$ "Consistency: Object: Instance State Machine: Cardinality of an identifier is zero. " //$NON-NLS-1$ + "Actual Value: " + Integer.toString(objs39207.length)); // $NON-NLS-1$ } else { Exception e = new Exception(); CorePlugin.logError( "Consistency: Object: Instance State Machine: Cardinality of an identifier is zero. " //$NON-NLS-1$ + "Actual Value: " //$NON-NLS-1$ + Integer.toString(objs39207.length), e); } retval = false; } if (((objs39207.length) > 1)) { if (CorePlugin.getDefault().isDebugging()) { Ooaofooa.log.println( ILogger.CONSISTENCY, "Instance State Machine", //$NON-NLS-1$ "Consistency: Object: Instance State Machine: Cardinality of an identifier is greater than 1. " //$NON-NLS-1$ + "Actual Value: " //$NON-NLS-1$ + Integer.toString(objs39207.length) + " SM_ID: " + "Not Printable"); //$NON-NLS-1$ } else { Exception e = new Exception(); CorePlugin.logError( "Consistency: Object: Instance State Machine: Cardinality of an identifier is greater than 1. " //$NON-NLS-1$ + "Actual Value: " //$NON-NLS-1$ + Integer.toString(objs39207.length) + " SM_ID: " + "Not Printable", e); //$NON-NLS-1$ } retval = false; } // Instance State Machine is a subtype in association: rel.Numb = 517 // The supertype class is: State Machine class StateMachine_c_test39213_c implements ClassQueryInterface_c { StateMachine_c_test39213_c(java.util.UUID p39214) { m_p39214 = p39214; } private java.util.UUID m_p39214; public boolean evaluate(Object candidate) { StateMachine_c selected = (StateMachine_c) candidate; boolean retval = false; retval = (selected.getSm_id().equals(m_p39214)); return retval; } } StateMachine_c[] objs39212 = StateMachine_c.StateMachineInstances(modelRoot, new StateMachine_c_test39213_c(getSm_id())); if (((objs39212.length) != 1)) { if (CorePlugin.getDefault().isDebugging()) { Ooaofooa.log.println( ILogger.CONSISTENCY, "Instance State Machine", //$NON-NLS-1$ "Consistency: Object: Instance State Machine: Association: 517: Cardinality of a supertype is not equal to 1. " //$NON-NLS-1$ + "Actual Value: " + Integer.toString(objs39212.length)); // $NON-NLS-1$ } else { Exception e = new Exception(); CorePlugin.logError( "Consistency: Object: Instance State Machine: Association: 517: Cardinality of a supertype is not equal to 1. " //$NON-NLS-1$ + "Actual Value: " //$NON-NLS-1$ + Integer.toString(objs39212.length), e); } retval = false; } // Instance State Machine is a referring class in association: rel.Numb = 518 // The participating class is: Model Class class ModelClass_c_test39216_c implements ClassQueryInterface_c { ModelClass_c_test39216_c(java.util.UUID p39217) { m_p39217 = p39217; } private java.util.UUID m_p39217; public boolean evaluate(Object candidate) { ModelClass_c selected = (ModelClass_c) candidate; boolean retval = false; retval = (selected.getObj_id().equals(m_p39217)); return retval; } } ModelClass_c[] objs39215 = ModelClass_c.ModelClassInstances(modelRoot, new ModelClass_c_test39216_c(getObj_id())); // The participant is unconditional // The multiplicity of the participant is one if (((objs39215.length) != 1)) { if (CorePlugin.getDefault().isDebugging()) { Ooaofooa.log.println( ILogger.CONSISTENCY, "Instance State Machine", //$NON-NLS-1$ "Consistency: Object: Instance State Machine: Association: 518: Cardinality of a participant is not equal to 1. " //$NON-NLS-1$ + "Actual Value: " //$NON-NLS-1$ + Integer.toString(objs39215.length) + " Obj_ID: " + "Not Printable"); //$NON-NLS-1$ } else { Exception e = new Exception(); CorePlugin.logError( "Consistency: Object: Instance State Machine: Association: 518: Cardinality of a participant is not equal to 1. " //$NON-NLS-1$ + "Actual Value: " //$NON-NLS-1$ + Integer.toString(objs39215.length) + " Obj_ID: " + "Not Printable", e); //$NON-NLS-1$ } retval = false; } return retval; }
public boolean evaluate(Object candidate) { InstanceStateMachine_c selected = (InstanceStateMachine_c) candidate; boolean retval = false; retval = (selected.getSm_id().equals(m_p39209)); return retval; }