| author | Rainer Pielmann | 2012-08-20 06:35:05 (EDT) |
|---|---|---|
| committer | Manik Kishore | 2012-08-20 06:35:05 (EDT) |
| commit | a47d1f00e5ae28aa0d3f1461daa2da5182fd5916 (patch) (side-by-side diff) | |
| tree | 86c2542383bddef7a3a2111adde6424596ee0a93 | |
| parent | d913802992c8adba9739966269a27c24f108fad7 (diff) | |
| download | org.eclipse.stardust.ide-a47d1f00e5ae28aa0d3f1461daa2da5182fd5916.zip org.eclipse.stardust.ide-a47d1f00e5ae28aa0d3f1461daa2da5182fd5916.tar.gz org.eclipse.stardust.ide-a47d1f00e5ae28aa0d3f1461daa2da5182fd5916.tar.bz2 | |
CRNT-25760 Refactor/Clean up MB Facade: Refactor finder-Methods
git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ide@58534 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
2 files changed, 162 insertions, 2 deletions
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java index ac44277..732ef12 100644 --- a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java +++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java @@ -808,6 +808,27 @@ public class MBFacade throw new ObjectNotFoundException("Process Definition " + id + " does not exist.");
}
+
+ /**
+ *
+ * @param processFullID
+ * @return processDefinition
+ */
+ public ProcessDefinitionType findProcessDefinition(String processFullID)
+ {
+ String modelID = this.getModelId(processFullID);
+ String processID = stripFullId(processFullID);
+ ModelType model = findModel(modelID);
+ for (ProcessDefinitionType processDefinition : model.getProcessDefinition())
+ {
+ if (processDefinition.getId().equals(processID))
+ {
+ return processDefinition;
+ }
+ }
+
+ throw new ObjectNotFoundException("Process Definition " + processFullID + " does not exist.");
+ }
/**
*
@@ -824,7 +845,7 @@ public class MBFacade *
* @param model
* @param id
- * @return
+ * @return application
*/
public ApplicationType findApplication(ModelType model, String id)
{
@@ -838,6 +859,28 @@ public class MBFacade throw new ObjectNotFoundException("Application " + id + " does not exist.");
}
+
+ /**
+ *
+ * @param model
+ * @param fullApplicationID
+ * @return application
+ */
+ public ApplicationType findApplication(String fullApplicationID)
+ {
+ String modelID = this.getModelId(fullApplicationID);
+ String applicationID = stripFullId(fullApplicationID);
+ ModelType model = findModel(modelID);
+ for (ApplicationType application : model.getApplication())
+ {
+ if (application.getId().equals(applicationID))
+ {
+ return application;
+ }
+ }
+
+ throw new ObjectNotFoundException("Application " + fullApplicationID + " does not exist.");
+ }
/**
*
@@ -899,7 +942,29 @@ public class MBFacade throw new ObjectNotFoundException("Type declaration " + id + " does not exist.");
}
+
+ /**
+ *
+ * @param fullTypeID
+ * @return typeDeclaration
+ */
+ public TypeDeclarationType findTypeDeclaration(String fullTypeID)
+ {
+ String modelID = this.getModelId(fullTypeID);
+ String typeID = stripFullId(fullTypeID);
+ ModelType model = findModel(modelID);
+ for (TypeDeclarationType typeDeclaration : model.getTypeDeclarations()
+ .getTypeDeclaration())
+ {
+ if (typeDeclaration.getId().equals(typeID))
+ {
+ return typeDeclaration;
+ }
+ }
+ throw new ObjectNotFoundException("Type declaration " + fullTypeID + " does not exist.");
+ }
+
/**
*
* @param model
@@ -957,6 +1022,28 @@ public class MBFacade throw new ObjectNotFoundException("Data " + id + " does not exist.");
}
+
+ /**
+ *
+ * @param model
+ * @param dataFullID
+ * @return data
+ */
+ public DataType findData(String dataFullID)
+ {
+ String modelID = this.getModelId(dataFullID);
+ String dataID = stripFullId(dataFullID);
+ ModelType model = findModel(modelID);
+ for (DataType data : model.getData())
+ {
+ if (data.getId().equals(dataID))
+ {
+ return data;
+ }
+ }
+
+ throw new ObjectNotFoundException("Data " + dataFullID + " does not exist.");
+ }
/**
*
@@ -984,6 +1071,36 @@ public class MBFacade throw new ObjectNotFoundException("Participant " + id + " does not exist.");
}
+
+ /**
+ *
+ * @param model
+ * @param fullParticipantID
+ * @return participant
+ */
+ public IModelParticipant findParticipant(String fullParticipantID)
+ {
+ String modelID = this.getModelId(fullParticipantID);
+ String participantID = stripFullId(fullParticipantID);
+ ModelType model = findModel(modelID);
+ for (RoleType role : model.getRole())
+ {
+ if (role.getId().equals(participantID))
+ {
+ return role;
+ }
+ }
+
+ for (OrganizationType organization : model.getOrganization())
+ {
+ if (organization.getId().equals(participantID))
+ {
+ return organization;
+ }
+ }
+
+ throw new ObjectNotFoundException("Participant " + fullParticipantID + " does not exist.");
+ }
/**
*
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java b/model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java index 1a8e345..ae50683 100644 --- a/model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java +++ b/model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java @@ -21,19 +21,30 @@ import org.eclipse.stardust.model.xpdl.builder.utils.MBFacade; import org.eclipse.stardust.model.xpdl.builder.utils.ModelerConstants;
import org.eclipse.stardust.model.xpdl.builder.utils.XpdlModelIoUtils;
import org.eclipse.stardust.model.xpdl.carnot.ActivityType;
+import org.eclipse.stardust.model.xpdl.carnot.ApplicationType;
import org.eclipse.stardust.model.xpdl.carnot.DataType;
+import org.eclipse.stardust.model.xpdl.carnot.IModelParticipant;
import org.eclipse.stardust.model.xpdl.carnot.LaneSymbol;
import org.eclipse.stardust.model.xpdl.carnot.ModelType;
import org.eclipse.stardust.model.xpdl.carnot.ProcessDefinitionType;
+import org.eclipse.stardust.model.xpdl.carnot.RoleType;
import org.eclipse.stardust.model.xpdl.xpdl2.ExternalPackage;
import org.eclipse.stardust.model.xpdl.xpdl2.ExternalPackages;
+import org.eclipse.stardust.model.xpdl.xpdl2.TypeDeclarationType;
import org.junit.Before;
import org.junit.Test;
public class CrossModelSupportModelBuilderTest { - private InMemoryModelManagementStrategy strategy; + private InMemoryModelManagementStrategy strategy;
+ private DataType searchedDataType1;
+ private DataType searchedDataType2;
+
+ private ApplicationType searchedApplicationType;
+ private ProcessDefinitionType searchedProcess;
+ private TypeDeclarationType searchedType;
+ private IModelParticipant searchedRole; @Before public void initCrossModeling() @@ -82,6 +93,15 @@ public class CrossModelSupportModelBuilderTest facade.createActivitySymbol(providerModel, activity1, providedProcess2, laneSymbol.getId(), 40, 40, 180, 50);
facade.createDataSymbol(providerModel, localComposite, providedProcess2, laneSymbol.getId(), 100, 100, 40, 80);
+ //Search & Find
+ searchedDataType1 = facade.findData("ProviderModel:ProvidedPrimitive");
+ searchedDataType2 = facade.findData(providerModel, "ProvidedPrimitive");
+ searchedApplicationType = facade.findApplication("ProviderModel:WebService");
+ searchedProcess = facade.findProcessDefinition("ProviderModel:ProvidedProcess2");
+ searchedType = facade.findTypeDeclaration("ProviderModel:ProvidedComposite");
+ searchedRole = facade.findParticipant("ProviderModel:Administrator");
+
+
//Store
byte[] modelContent = XpdlModelIoUtils.saveModel(providerModel);
@@ -102,6 +122,29 @@ public class CrossModelSupportModelBuilderTest assertThat(externalPackage.getHref(), is("ProviderModel")); assertThat(externalPackage.getId(), is("ProviderModel")); assertThat(externalPackage.getName(), is("ProviderModel")); + }
+
+ @Test
+ public void verifySearchAndFind()
+ {
+ assertThat(searchedDataType1, not(is(nullValue())));
+ assertThat(searchedDataType1.getId(),is("ProvidedPrimitive"));
+
+ assertThat(searchedDataType2, not(is(nullValue())));
+ assertThat(searchedDataType2.getId(),is("ProvidedPrimitive"));
+
+ assertThat(searchedApplicationType, not(is(nullValue())));
+ assertThat(searchedApplicationType.getId(),is("WebService"));
+
+ assertThat(searchedProcess, not(is(nullValue())));
+ assertThat(searchedProcess.getId(),is("ProvidedProcess2"));
+
+ assertThat(searchedType, not(is(nullValue())));
+ assertThat(searchedType.getId(),is("ProvidedComposite"));
+
+ assertThat(searchedRole, not(is(nullValue())));
+ assertThat(searchedRole.getId(),is("Administrator"));
+
} |

