Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2010-07-24 17:38:31 +0000
committerrbrooks2010-07-24 17:38:31 +0000
commit4081f04850d3eff9eb1bd7241763707bfbb43a45 (patch)
tree258620df94d4b24077ff103a6c4dea9cb78493fb /plugins/org.eclipse.osee.framework.core.dsl.integration
parent4ed8bddc791fda93940f238c5135556a07041dc0 (diff)
downloadorg.eclipse.osee-4081f04850d3eff9eb1bd7241763707bfbb43a45.tar.gz
org.eclipse.osee-4081f04850d3eff9eb1bd7241763707bfbb43a45.tar.xz
org.eclipse.osee-4081f04850d3eff9eb1bd7241763707bfbb43a45.zip
applied Eclipse source cleanup
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.dsl.integration')
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java4
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/CreateOseeTypeChangesReportOperation.java202
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/EMFCompareOperation.java65
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ModelUtil.java290
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslToAccessDataOperation.java62
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java462
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeTypeCache.java100
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java458
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/Activator.java22
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java205
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceRegHandler.java64
11 files changed, 965 insertions, 969 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java
index 2103bd30740..0ae280b2600 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java
@@ -21,7 +21,7 @@ import org.eclipse.osee.framework.core.model.access.AccessDetail;
*/
public interface AccessModelInterpreter {
- AccessContext getContext(Collection<AccessContext> contexts, AccessContextId contextId) throws OseeCoreException;
+ AccessContext getContext(Collection<AccessContext> contexts, AccessContextId contextId) throws OseeCoreException;
- void computeAccessDetails(AccessContext context, Object objectToCheck, Collection<AccessDetail<?>> details) throws OseeCoreException;
+ void computeAccessDetails(AccessContext context, Object objectToCheck, Collection<AccessDetail<?>> details) throws OseeCoreException;
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/CreateOseeTypeChangesReportOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/CreateOseeTypeChangesReportOperation.java
index 80cfd371eae..808d4cee00a 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/CreateOseeTypeChangesReportOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/CreateOseeTypeChangesReportOperation.java
@@ -31,112 +31,112 @@ import org.eclipse.osee.framework.jdk.core.util.Collections;
* @author Roberto E. Escobar
*/
public class CreateOseeTypeChangesReportOperation extends AbstractOperation {
- private final OseeTypeCache cache;
- private final List<TableData> tabs;
+ private final OseeTypeCache cache;
+ private final List<TableData> tabs;
- public CreateOseeTypeChangesReportOperation(OseeTypeCache cache, List<TableData> tabs) {
- super("Report Osee Type Changes", Activator.PLUGIN_ID);
- this.cache = cache;
- this.tabs = tabs;
- }
+ public CreateOseeTypeChangesReportOperation(OseeTypeCache cache, List<TableData> tabs) {
+ super("Report Osee Type Changes", Activator.PLUGIN_ID);
+ this.cache = cache;
+ this.tabs = tabs;
+ }
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- createOseeEnumTypeReport(tabs, cache.getEnumTypeCache().getAllDirty());
- createAttributeTypeReport(tabs, cache.getAttributeTypeCache().getAllDirty());
- createArtifactTypeReport(tabs, cache.getArtifactTypeCache());
- createRelationTypeReport(tabs, cache.getRelationTypeCache().getAllDirty());
- }
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ createOseeEnumTypeReport(tabs, cache.getEnumTypeCache().getAllDirty());
+ createAttributeTypeReport(tabs, cache.getAttributeTypeCache().getAllDirty());
+ createArtifactTypeReport(tabs, cache.getArtifactTypeCache());
+ createRelationTypeReport(tabs, cache.getRelationTypeCache().getAllDirty());
+ }
- private String[] getColumns(Collection<?> types) {
- List<String> columns = new ArrayList<String>();
- columns.add("Name");
- columns.add("StorageState");
- if (!types.isEmpty()) {
- AbstractOseeType type = (AbstractOseeType) types.iterator().next();
- columns.addAll(type.getFieldNames());
- }
- return columns.toArray(new String[columns.size()]);
- }
+ private String[] getColumns(Collection<?> types) {
+ List<String> columns = new ArrayList<String>();
+ columns.add("Name");
+ columns.add("StorageState");
+ if (!types.isEmpty()) {
+ AbstractOseeType type = (AbstractOseeType) types.iterator().next();
+ columns.addAll(type.getFieldNames());
+ }
+ return columns.toArray(new String[columns.size()]);
+ }
- private void createArtifactTypeReport(List<TableData> tabs, ArtifactTypeCache cache) throws OseeCoreException {
- List<String[]> rows = new ArrayList<String[]>();
- Collection<ArtifactType> types = cache.getAllDirty();
- String[] columns = getColumns(types);
- for (ArtifactType type : types) {
- List<String> data = new ArrayList<String>(columns.length);
- data.add(type.getName());
- data.add(type.getStorageState().name());
- for (String fieldName : type.getFieldNames()) {
- boolean isDirty = type.isFieldDirty(fieldName);
- if (isDirty && ArtifactType.ARTIFACT_INHERITANCE_FIELD_KEY.equals(fieldName)) {
- data.add(type.getSuperArtifactTypes().toString());
- } else if (isDirty && ArtifactType.ARTIFACT_TYPE_ATTRIBUTES_FIELD_KEY.equals(fieldName)) {
- data.add(type.getLocalAttributeTypes().toString());
- } else {
- data.add(String.valueOf(isDirty));
- }
- }
- rows.add(data.toArray(new String[data.size()]));
- }
- tabs.add(new TableData("Artifact Types", columns, rows));
- }
+ private void createArtifactTypeReport(List<TableData> tabs, ArtifactTypeCache cache) throws OseeCoreException {
+ List<String[]> rows = new ArrayList<String[]>();
+ Collection<ArtifactType> types = cache.getAllDirty();
+ String[] columns = getColumns(types);
+ for (ArtifactType type : types) {
+ List<String> data = new ArrayList<String>(columns.length);
+ data.add(type.getName());
+ data.add(type.getStorageState().name());
+ for (String fieldName : type.getFieldNames()) {
+ boolean isDirty = type.isFieldDirty(fieldName);
+ if (isDirty && ArtifactType.ARTIFACT_INHERITANCE_FIELD_KEY.equals(fieldName)) {
+ data.add(type.getSuperArtifactTypes().toString());
+ } else if (isDirty && ArtifactType.ARTIFACT_TYPE_ATTRIBUTES_FIELD_KEY.equals(fieldName)) {
+ data.add(type.getLocalAttributeTypes().toString());
+ } else {
+ data.add(String.valueOf(isDirty));
+ }
+ }
+ rows.add(data.toArray(new String[data.size()]));
+ }
+ tabs.add(new TableData("Artifact Types", columns, rows));
+ }
- private void createAttributeTypeReport(List<TableData> tabs, Collection<AttributeType> types) throws OseeCoreException {
- List<String[]> rows = new ArrayList<String[]>();
- String[] columns = getColumns(types);
- for (AttributeType type : types) {
- List<String> data = new ArrayList<String>();
- data.add(type.getName());
- data.add(type.getStorageState().name());
- for (String fieldName : type.getFieldNames()) {
- data.add(String.valueOf(type.isFieldDirty(fieldName)));
- }
- rows.add(data.toArray(new String[data.size()]));
- }
- tabs.add(new TableData("Attribute Types", columns, rows));
- }
+ private void createAttributeTypeReport(List<TableData> tabs, Collection<AttributeType> types) throws OseeCoreException {
+ List<String[]> rows = new ArrayList<String[]>();
+ String[] columns = getColumns(types);
+ for (AttributeType type : types) {
+ List<String> data = new ArrayList<String>();
+ data.add(type.getName());
+ data.add(type.getStorageState().name());
+ for (String fieldName : type.getFieldNames()) {
+ data.add(String.valueOf(type.isFieldDirty(fieldName)));
+ }
+ rows.add(data.toArray(new String[data.size()]));
+ }
+ tabs.add(new TableData("Attribute Types", columns, rows));
+ }
- private void createRelationTypeReport(List<TableData> tabs, Collection<RelationType> types) throws OseeCoreException {
- List<String[]> rows = new ArrayList<String[]>();
- String[] columns = getColumns(types);
- for (RelationType type : types) {
- List<String> data = new ArrayList<String>();
- data.add(type.getName());
- data.add(type.getStorageState().name());
- for (String fieldName : type.getFieldNames()) {
- data.add(String.valueOf(type.isFieldDirty(fieldName)));
- }
- rows.add(data.toArray(new String[data.size()]));
- }
- tabs.add(new TableData("Relation Types", columns, rows));
- }
+ private void createRelationTypeReport(List<TableData> tabs, Collection<RelationType> types) throws OseeCoreException {
+ List<String[]> rows = new ArrayList<String[]>();
+ String[] columns = getColumns(types);
+ for (RelationType type : types) {
+ List<String> data = new ArrayList<String>();
+ data.add(type.getName());
+ data.add(type.getStorageState().name());
+ for (String fieldName : type.getFieldNames()) {
+ data.add(String.valueOf(type.isFieldDirty(fieldName)));
+ }
+ rows.add(data.toArray(new String[data.size()]));
+ }
+ tabs.add(new TableData("Relation Types", columns, rows));
+ }
- private void createOseeEnumTypeReport(List<TableData> tabs, Collection<OseeEnumType> types) throws OseeCoreException {
- List<String[]> rows = new ArrayList<String[]>();
- String[] columns = getColumns(types);
- for (OseeEnumType type : types) {
- List<String> data = new ArrayList<String>();
- data.add(type.getName());
- data.add(type.getStorageState().name());
- for (String fieldName : type.getFieldNames()) {
- boolean isDirty = type.isFieldDirty(fieldName);
- if (isDirty && OseeEnumType.OSEE_ENUM_TYPE_ENTRIES_FIELD.equals(fieldName)) {
- List<String> dirtyItems = new ArrayList<String>();
- for (OseeEnumEntry entry : type.values()) {
- if (entry.isDirty()) {
- dirtyItems.add(String.format("*{%s}", entry.toString()));
- } else {
- dirtyItems.add(entry.toString());
- }
- }
- data.add(Collections.toString(dirtyItems, ","));
- } else {
- data.add(String.valueOf(isDirty));
- }
- }
- rows.add(data.toArray(new String[data.size()]));
- }
- tabs.add(new TableData("OseeEnum Types", columns, rows));
- }
+ private void createOseeEnumTypeReport(List<TableData> tabs, Collection<OseeEnumType> types) throws OseeCoreException {
+ List<String[]> rows = new ArrayList<String[]>();
+ String[] columns = getColumns(types);
+ for (OseeEnumType type : types) {
+ List<String> data = new ArrayList<String>();
+ data.add(type.getName());
+ data.add(type.getStorageState().name());
+ for (String fieldName : type.getFieldNames()) {
+ boolean isDirty = type.isFieldDirty(fieldName);
+ if (isDirty && OseeEnumType.OSEE_ENUM_TYPE_ENTRIES_FIELD.equals(fieldName)) {
+ List<String> dirtyItems = new ArrayList<String>();
+ for (OseeEnumEntry entry : type.values()) {
+ if (entry.isDirty()) {
+ dirtyItems.add(String.format("*{%s}", entry.toString()));
+ } else {
+ dirtyItems.add(entry.toString());
+ }
+ }
+ data.add(Collections.toString(dirtyItems, ","));
+ } else {
+ data.add(String.valueOf(isDirty));
+ }
+ }
+ rows.add(data.toArray(new String[data.size()]));
+ }
+ tabs.add(new TableData("OseeEnum Types", columns, rows));
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/EMFCompareOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/EMFCompareOperation.java
index 6ac1198f0bf..fd8d06f3c98 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/EMFCompareOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/EMFCompareOperation.java
@@ -11,7 +11,6 @@
package org.eclipse.osee.framework.core.dsl.integration;
import java.util.Calendar;
-
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSnapshot;
@@ -30,43 +29,41 @@ import org.eclipse.osee.framework.core.operation.AbstractOperation;
*/
public class EMFCompareOperation extends AbstractOperation {
- private final EObject ancestor;
- private final EObject modified;
- private final ComparisonResourceSnapshot comparisonSnapshot;
+ private final EObject ancestor;
+ private final EObject modified;
+ private final ComparisonResourceSnapshot comparisonSnapshot;
- public EMFCompareOperation(EObject ancestor, EObject modified,
- ComparisonResourceSnapshot comparisonSnapshot) {
- super("Compare", EMFCompareOperation.class.getPackage().getName());
- this.ancestor = ancestor;
- this.modified = modified;
- this.comparisonSnapshot = comparisonSnapshot;
- }
+ public EMFCompareOperation(EObject ancestor, EObject modified, ComparisonResourceSnapshot comparisonSnapshot) {
+ super("Compare", EMFCompareOperation.class.getPackage().getName());
+ this.ancestor = ancestor;
+ this.modified = modified;
+ this.comparisonSnapshot = comparisonSnapshot;
+ }
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- OseeDslStandaloneSetup.doSetup();
- URI uri = URI.createURI("http://org.eclipse/osee/types/oseetypecache2");
- // URI uri = URI.createURI("dummy:/ancestor.osee");
- // final ResourceSet resourceSet1 = new ResourceSetImpl();
- // Resource resource1 = resourceSet1.createResource(uri);
- Resource resource1 = new ResourceImpl(uri);
- resource1.getContents().add(ancestor);
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ OseeDslStandaloneSetup.doSetup();
+ URI uri = URI.createURI("http://org.eclipse/osee/types/oseetypecache2");
+ // URI uri = URI.createURI("dummy:/ancestor.osee");
+ // final ResourceSet resourceSet1 = new ResourceSetImpl();
+ // Resource resource1 = resourceSet1.createResource(uri);
+ Resource resource1 = new ResourceImpl(uri);
+ resource1.getContents().add(ancestor);
- // final ResourceSet resourceSet2 = new ResourceSetImpl();
- // Resource resource2 = resourceSet2.createResource(uri);
- Resource resource2 = new ResourceImpl(uri);
- resource2.getContents().add(modified);
+ // final ResourceSet resourceSet2 = new ResourceSetImpl();
+ // Resource resource2 = resourceSet2.createResource(uri);
+ Resource resource2 = new ResourceImpl(uri);
+ resource2.getContents().add(modified);
- final MatchModel match = MatchService.doMatch(ancestor, modified,
- ancestor, null);
- monitor.worked(calculateWork(0.40));
+ final MatchModel match = MatchService.doMatch(ancestor, modified, ancestor, null);
+ monitor.worked(calculateWork(0.40));
- final DiffModel diff = DiffService.doDiff(match, true);
- monitor.worked(calculateWork(0.40));
+ final DiffModel diff = DiffService.doDiff(match, true);
+ monitor.worked(calculateWork(0.40));
- comparisonSnapshot.setDate(Calendar.getInstance().getTime());
- comparisonSnapshot.setMatch(match);
- comparisonSnapshot.setDiff(diff);
- monitor.worked(calculateWork(0.20));
- }
+ comparisonSnapshot.setDate(Calendar.getInstance().getTime());
+ comparisonSnapshot.setMatch(match);
+ comparisonSnapshot.setDiff(diff);
+ monitor.worked(calculateWork(0.20));
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ModelUtil.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ModelUtil.java
index 9b8b458c631..6f0d6e93bee 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ModelUtil.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ModelUtil.java
@@ -41,149 +41,149 @@ import com.google.inject.Injector;
*/
public final class ModelUtil {
- private ModelUtil() {
- }
-
- // private void loadDependencies(OseeTypeModel baseModel, List<OseeTypeModel> models) throws OseeCoreException, URISyntaxException {
- // // This is commented out cause we're using a combined file. Once combined files
- // // are no longer generated, this should be uncommented.
- // // for (Import dependant : baseModel.getImports()) {
- // // OseeTypeModel childModel = OseeTypeModelUtil.loadModel(context, new URI(dependant.getImportURI()));
- // // loadDependencies(childModel, models);
- // // System.out.println("depends on: " + dependant.getImportURI());
- // // }
- // // System.out.println("Added on: " + baseModel.eResource().getURI());
- // models.add(baseModel);
- //
- // }
-
- // OseeTypeModel targetModel = null;
- // try {
- // targetModel = OseeTypeModelUtil.loadModel(context, resource);
- // } catch (OseeCoreException ex) {
- // throw new OseeWrappedException(String.format("Error loading: [%s]", resource), ex);
- // }
- // loadDependencies(targetModel, models);
-
- public static OseeDsl loadModel(String uri, String xTextData) throws OseeCoreException {
- try {
- OseeDslStandaloneSetup setup = new OseeDslStandaloneSetup();
- Injector injector = setup.createInjectorAndDoEMFRegistration();
- XtextResourceSet set = injector.getInstance(XtextResourceSet.class);
-
- set.setClasspathURIContext(ModelUtil.class);
- set.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
-
- Resource resource = set.createResource(URI.createURI(uri));
- resource.load(new ByteArrayInputStream(xTextData.getBytes("UTF-8")), set.getLoadOptions());
- OseeDsl model = (OseeDsl) resource.getContents().get(0);
- for (Diagnostic diagnostic : resource.getErrors()) {
- throw new OseeStateException(diagnostic.toString());
- }
- return model;
- } catch (IOException ex) {
- throw new OseeWrappedException(ex);
- }
- }
-
- public static OseeDsl loadModel(InputStream inputStream, boolean isZipped) throws OseeCoreException {
- Injector injector = new OseeDslStandaloneSetup().createInjectorAndDoEMFRegistration();
- XtextResource resource = injector.getInstance(XtextResource.class);
-
- Map<String, Boolean> options = new HashMap<String, Boolean>();
- options.put(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
- if (isZipped) {
- options.put(XtextResource.OPTION_ZIP, Boolean.TRUE);
- }
- try {
- resource.setURI(URI.createURI("http://www.eclipse.org/osee/framework/OseeTypes"));
- resource.load(inputStream, options);
- } catch (IOException ex) {
- throw new OseeWrappedException(ex);
- }
- OseeDsl model = (OseeDsl) resource.getContents().get(0);
- for (Diagnostic diagnostic : resource.getErrors()) {
- throw new OseeStateException(diagnostic.toString());
- }
- return model;
- }
-
- public static OseeDsl loadModel(Object context, java.net.URI target) throws OseeCoreException {
- String uri = target.toASCIIString();
- Injector injector = new OseeDslStandaloneSetup().createInjectorAndDoEMFRegistration();
- XtextResourceSet set = injector.getInstance(XtextResourceSet.class);
-
- set.setClasspathURIContext(context);
- set.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
-
- Resource resource = set.getResource(URI.createURI(uri), true);
- OseeDsl model = (OseeDsl) resource.getContents().get(0);
- for (Diagnostic diagnostic : resource.getErrors()) {
- throw new OseeStateException(diagnostic.toString());
- }
- return model;
- }
-
- public static void saveModel(java.net.URI uri, OseeDsl model) throws IOException {
- OseeDslStandaloneSetup.doSetup();
-
- ResourceSet resourceSet = new ResourceSetImpl();
- Resource resource = resourceSet.createResource(URI.createURI(uri.toASCIIString()));
- resource.getContents().add(model);
-
- Map<String, Boolean> options = new HashMap<String, Boolean>();
- // options.put(XtextResource.OPTION_FORMAT, Boolean.TRUE);
- SaveOptions saveOptions = SaveOptions.getOptions(options);
- resource.save(saveOptions.toOptionsMap());
- }
-
- public static void saveModel(OseeDsl model, String uri, OutputStream outputStream, boolean isZipped) throws IOException {
- OseeDslStandaloneSetup.doSetup();
-
- ResourceSet resourceSet = new ResourceSetImpl();
- Resource resource = resourceSet.createResource(URI.createURI(uri));
- resource.getContents().add(model);
-
- Map<String, Boolean> options = new HashMap<String, Boolean>();
- // options.put(XtextResource.OPTION_FORMAT, Boolean.TRUE);
- if (isZipped) {
- options.put(XtextResource.OPTION_ZIP, Boolean.TRUE);
- }
- SaveOptions saveOptions = SaveOptions.getOptions(options);
- resource.save(outputStream, saveOptions.toOptionsMap());
- }
-
- private static void storeModel(OutputStream outputStream, EObject object, String uri, Map<String, Boolean> options) throws OseeCoreException {
- Resource resource = new XMLResourceImpl();
- try {
- resource.setURI(URI.createURI(uri));
- resource.getContents().add(object);
- resource.save(outputStream, options);
- } catch (IOException ex) {
- throw new OseeWrappedException(ex);
- }
- }
-
- public static String modelToString(EObject object, String uri, Map<String, Boolean> options) throws OseeCoreException {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- storeModel(outputStream, object, uri, options);
- try {
- return outputStream.toString("UTF-8");
- } catch (UnsupportedEncodingException ex) {
- throw new OseeWrappedException(ex);
- }
- }
-
- public static ComparisonSnapshot loadComparisonSnapshot(String compareName, String compareData) throws OseeCoreException {
- ComparisonSnapshot snapshot = null;
- try {
- ResourceSet resourceSet = new ResourceSetImpl();
- Resource resource = resourceSet.createResource(URI.createURI(compareName));
- resource.load(new ByteArrayInputStream(compareData.getBytes("UTF-8")), resourceSet.getLoadOptions());
- snapshot = (ComparisonSnapshot) resource.getContents().get(0);
- } catch (IOException ex) {
- throw new OseeWrappedException(ex);
- }
- return snapshot;
- }
+ private ModelUtil() {
+ }
+
+ // private void loadDependencies(OseeTypeModel baseModel, List<OseeTypeModel> models) throws OseeCoreException, URISyntaxException {
+ // // This is commented out cause we're using a combined file. Once combined files
+ // // are no longer generated, this should be uncommented.
+ // // for (Import dependant : baseModel.getImports()) {
+ // // OseeTypeModel childModel = OseeTypeModelUtil.loadModel(context, new URI(dependant.getImportURI()));
+ // // loadDependencies(childModel, models);
+ // // System.out.println("depends on: " + dependant.getImportURI());
+ // // }
+ // // System.out.println("Added on: " + baseModel.eResource().getURI());
+ // models.add(baseModel);
+ //
+ // }
+
+ // OseeTypeModel targetModel = null;
+ // try {
+ // targetModel = OseeTypeModelUtil.loadModel(context, resource);
+ // } catch (OseeCoreException ex) {
+ // throw new OseeWrappedException(String.format("Error loading: [%s]", resource), ex);
+ // }
+ // loadDependencies(targetModel, models);
+
+ public static OseeDsl loadModel(String uri, String xTextData) throws OseeCoreException {
+ try {
+ OseeDslStandaloneSetup setup = new OseeDslStandaloneSetup();
+ Injector injector = setup.createInjectorAndDoEMFRegistration();
+ XtextResourceSet set = injector.getInstance(XtextResourceSet.class);
+
+ set.setClasspathURIContext(ModelUtil.class);
+ set.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
+
+ Resource resource = set.createResource(URI.createURI(uri));
+ resource.load(new ByteArrayInputStream(xTextData.getBytes("UTF-8")), set.getLoadOptions());
+ OseeDsl model = (OseeDsl) resource.getContents().get(0);
+ for (Diagnostic diagnostic : resource.getErrors()) {
+ throw new OseeStateException(diagnostic.toString());
+ }
+ return model;
+ } catch (IOException ex) {
+ throw new OseeWrappedException(ex);
+ }
+ }
+
+ public static OseeDsl loadModel(InputStream inputStream, boolean isZipped) throws OseeCoreException {
+ Injector injector = new OseeDslStandaloneSetup().createInjectorAndDoEMFRegistration();
+ XtextResource resource = injector.getInstance(XtextResource.class);
+
+ Map<String, Boolean> options = new HashMap<String, Boolean>();
+ options.put(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
+ if (isZipped) {
+ options.put(Resource.OPTION_ZIP, Boolean.TRUE);
+ }
+ try {
+ resource.setURI(URI.createURI("http://www.eclipse.org/osee/framework/OseeTypes"));
+ resource.load(inputStream, options);
+ } catch (IOException ex) {
+ throw new OseeWrappedException(ex);
+ }
+ OseeDsl model = (OseeDsl) resource.getContents().get(0);
+ for (Diagnostic diagnostic : resource.getErrors()) {
+ throw new OseeStateException(diagnostic.toString());
+ }
+ return model;
+ }
+
+ public static OseeDsl loadModel(Object context, java.net.URI target) throws OseeCoreException {
+ String uri = target.toASCIIString();
+ Injector injector = new OseeDslStandaloneSetup().createInjectorAndDoEMFRegistration();
+ XtextResourceSet set = injector.getInstance(XtextResourceSet.class);
+
+ set.setClasspathURIContext(context);
+ set.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
+
+ Resource resource = set.getResource(URI.createURI(uri), true);
+ OseeDsl model = (OseeDsl) resource.getContents().get(0);
+ for (Diagnostic diagnostic : resource.getErrors()) {
+ throw new OseeStateException(diagnostic.toString());
+ }
+ return model;
+ }
+
+ public static void saveModel(java.net.URI uri, OseeDsl model) throws IOException {
+ OseeDslStandaloneSetup.doSetup();
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource resource = resourceSet.createResource(URI.createURI(uri.toASCIIString()));
+ resource.getContents().add(model);
+
+ Map<String, Boolean> options = new HashMap<String, Boolean>();
+ // options.put(XtextResource.OPTION_FORMAT, Boolean.TRUE);
+ SaveOptions saveOptions = SaveOptions.getOptions(options);
+ resource.save(saveOptions.toOptionsMap());
+ }
+
+ public static void saveModel(OseeDsl model, String uri, OutputStream outputStream, boolean isZipped) throws IOException {
+ OseeDslStandaloneSetup.doSetup();
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource resource = resourceSet.createResource(URI.createURI(uri));
+ resource.getContents().add(model);
+
+ Map<String, Boolean> options = new HashMap<String, Boolean>();
+ // options.put(XtextResource.OPTION_FORMAT, Boolean.TRUE);
+ if (isZipped) {
+ options.put(Resource.OPTION_ZIP, Boolean.TRUE);
+ }
+ SaveOptions saveOptions = SaveOptions.getOptions(options);
+ resource.save(outputStream, saveOptions.toOptionsMap());
+ }
+
+ private static void storeModel(OutputStream outputStream, EObject object, String uri, Map<String, Boolean> options) throws OseeCoreException {
+ Resource resource = new XMLResourceImpl();
+ try {
+ resource.setURI(URI.createURI(uri));
+ resource.getContents().add(object);
+ resource.save(outputStream, options);
+ } catch (IOException ex) {
+ throw new OseeWrappedException(ex);
+ }
+ }
+
+ public static String modelToString(EObject object, String uri, Map<String, Boolean> options) throws OseeCoreException {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ storeModel(outputStream, object, uri, options);
+ try {
+ return outputStream.toString("UTF-8");
+ } catch (UnsupportedEncodingException ex) {
+ throw new OseeWrappedException(ex);
+ }
+ }
+
+ public static ComparisonSnapshot loadComparisonSnapshot(String compareName, String compareData) throws OseeCoreException {
+ ComparisonSnapshot snapshot = null;
+ try {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource resource = resourceSet.createResource(URI.createURI(compareName));
+ resource.load(new ByteArrayInputStream(compareData.getBytes("UTF-8")), resourceSet.getLoadOptions());
+ snapshot = (ComparisonSnapshot) resource.getContents().get(0);
+ } catch (IOException ex) {
+ throw new OseeWrappedException(ex);
+ }
+ return snapshot;
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslToAccessDataOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslToAccessDataOperation.java
index 7c585ba6a2b..df9f88c6aaa 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslToAccessDataOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslToAccessDataOperation.java
@@ -26,38 +26,38 @@ import org.eclipse.osee.framework.core.util.Conditions;
*/
public class OseeDslToAccessDataOperation extends AbstractOperation {
- private final AccessModelInterpreter interpreter;
- private final AccessData accessData;
- private final AccessContextId contextId;
- private final Collection<AccessContext> accessContexts;
- private final Collection<?> objectsToCheck;
+ private final AccessModelInterpreter interpreter;
+ private final AccessData accessData;
+ private final AccessContextId contextId;
+ private final Collection<AccessContext> accessContexts;
+ private final Collection<?> objectsToCheck;
- public OseeDslToAccessDataOperation(AccessModelInterpreter interpreter, AccessData accessData, AccessContextId contextId, Collection<AccessContext> accessContexts, Collection<?> objectsToCheck) {
- super("Access Dsl To AccessData", Activator.PLUGIN_ID);
- this.accessData = accessData;
- this.contextId = contextId;
- this.accessContexts = accessContexts;
- this.objectsToCheck = objectsToCheck;
- this.interpreter = interpreter;
- }
+ public OseeDslToAccessDataOperation(AccessModelInterpreter interpreter, AccessData accessData, AccessContextId contextId, Collection<AccessContext> accessContexts, Collection<?> objectsToCheck) {
+ super("Access Dsl To AccessData", Activator.PLUGIN_ID);
+ this.accessData = accessData;
+ this.contextId = contextId;
+ this.accessContexts = accessContexts;
+ this.objectsToCheck = objectsToCheck;
+ this.interpreter = interpreter;
+ }
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- AccessContext context = interpreter.getContext(accessContexts, contextId);
- Conditions.checkNotNull(context, "context", "Unable to find accessContext for [%s]", contextId);
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ AccessContext context = interpreter.getContext(accessContexts, contextId);
+ Conditions.checkNotNull(context, "context", "Unable to find accessContext for [%s]", contextId);
- if (objectsToCheck.isEmpty()) {
- monitor.worked(getTotalWorkUnits());
- } else {
- double stepAmount = 1.0 / objectsToCheck.size();
- int step = calculateWork(stepAmount);
- for (Object objectToCheck : objectsToCheck) {
- checkForCancelledStatus(monitor);
- Collection<AccessDetail<?>> accessDetail = new HashSet<AccessDetail<?>>();
- interpreter.computeAccessDetails(context, objectToCheck, accessDetail);
- accessData.addAll(objectToCheck, accessDetail);
- monitor.worked(step);
- }
- }
- }
+ if (objectsToCheck.isEmpty()) {
+ monitor.worked(getTotalWorkUnits());
+ } else {
+ double stepAmount = 1.0 / objectsToCheck.size();
+ int step = calculateWork(stepAmount);
+ for (Object objectToCheck : objectsToCheck) {
+ checkForCancelledStatus(monitor);
+ Collection<AccessDetail<?>> accessDetail = new HashSet<AccessDetail<?>>();
+ interpreter.computeAccessDetails(context, objectToCheck, accessDetail);
+ accessData.addAll(objectToCheck, accessDetail);
+ monitor.worked(step);
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java
index a72559d2d5d..a6b2baefe7a 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java
@@ -42,235 +42,235 @@ import org.eclipse.osee.framework.core.operation.AbstractOperation;
*/
public class OseeToXtextOperation extends AbstractOperation {
- private final OseeDsl oseeModel;
- private final OseeDslFactory factory;
- private final OseeTypeCache cache;
-
- public OseeToXtextOperation(OseeTypeCache cache, OseeDslFactory factory, OseeDsl oseeModel) {
- super("OSEE to Text Model", Activator.PLUGIN_ID);
- this.oseeModel = oseeModel;
- this.factory = factory;
- this.cache = cache;
- }
-
- private OseeDslFactory getFactory() {
- return factory;
- }
-
- private OseeDsl getModelByNamespace(String namespace) {
- return oseeModel;
- }
-
- private String getNamespace(String name) {
- String toReturn = "default";
- // if (Strings.isValid(name)) {
- // int index = name.lastIndexOf(".");
- // if (index > 0) {
- // toReturn = name.substring(0, index);
- // }
- // }
- return toReturn;
- }
-
- private String asPrimitiveType(String name) {
- return name.replace("org.eclipse.osee.framework.skynet.core.", "");
- }
-
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- double workPercentage = 1.0 / 6.0;
- populateEnumTypes(monitor, workPercentage);
- populateAttributeTypes(monitor, workPercentage);
- populateArtifactTypes(monitor, workPercentage);
- populateArtifactTypeInheritance(monitor, workPercentage);
- populateArtifactTypeAttributeTypes(monitor, workPercentage);
- populateRelationTypes(monitor, workPercentage);
- }
-
- private void populateEnumTypes(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
- Collection<OseeEnumType> enumTypes = cache.getEnumTypeCache().getAll();
- for (OseeEnumType enumType : enumTypes) {
- checkForCancelledStatus(monitor);
- XOseeEnumType modelType = getFactory().createXOseeEnumType();
-
- OseeDsl model = getModelByNamespace(getNamespace(enumType.getName()));
- model.getEnumTypes().add(modelType);
-
- modelType.setName(asQuoted(enumType.getName()));
- modelType.setTypeGuid(enumType.getGuid());
-
- for (OseeEnumEntry entry : enumType.values()) {
- checkForCancelledStatus(monitor);
- XOseeEnumEntry entryModelType = getFactory().createXOseeEnumEntry();
- modelType.getEnumEntries().add(entryModelType);
-
- entryModelType.setName(asQuoted(entry.getName()));
- entryModelType.setOrdinal(String.valueOf(entry.ordinal()));
- }
- }
- monitor.worked(calculateWork(workPercentage));
- }
-
- private void populateAttributeTypes(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
- monitor.setTaskName("Attribute Types");
- Collection<AttributeType> attributeTypes = cache.getAttributeTypeCache().getAll();
- for (AttributeType attributeType : attributeTypes) {
- checkForCancelledStatus(monitor);
- XAttributeType modelType = getFactory().createXAttributeType();
-
- OseeDsl model = getModelByNamespace(getNamespace(attributeType.getName()));
- model.getAttributeTypes().add(modelType);
-
- modelType.setName(asQuoted(attributeType.getName()));
- modelType.setTypeGuid(attributeType.getGuid());
- modelType.setBaseAttributeType(asPrimitiveType(attributeType.getBaseAttributeTypeId()));
- modelType.setDataProvider(asPrimitiveType(attributeType.getAttributeProviderId()));
- modelType.setMax(String.valueOf(attributeType.getMaxOccurrences()));
- modelType.setMin(String.valueOf(attributeType.getMinOccurrences()));
- modelType.setFileExtension(attributeType.getFileTypeExtension());
- modelType.setDescription(attributeType.getDescription());
- modelType.setDefaultValue(attributeType.getDefaultValue());
- modelType.setTaggerId(attributeType.getTaggerId());
-
- OseeEnumType oseeEnumType = attributeType.getOseeEnumType();
- if (oseeEnumType != null) {
- XOseeEnumType enumType = toModelEnumType(model, oseeEnumType);
- modelType.setEnumType(enumType);
- }
- }
- monitor.worked(calculateWork(workPercentage));
- }
-
- private XOseeEnumType toModelEnumType(OseeDsl model, OseeEnumType oseeEnumType) {
- String guid = oseeEnumType.getGuid();
- for (XOseeEnumType type : model.getEnumTypes()) {
- if (guid.equals(type.getTypeGuid())) {
- return type;
- }
- }
- return null;
- }
-
- private void populateArtifactTypes(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
- monitor.setTaskName("Artifact Types");
- Collection<ArtifactType> artifactTypes = cache.getArtifactTypeCache().getAll();
- for (ArtifactType artifactType : artifactTypes) {
- checkForCancelledStatus(monitor);
- XArtifactType modelType = getFactory().createXArtifactType();
-
- OseeDsl model = getModelByNamespace(getNamespace(artifactType.getName()));
- model.getArtifactTypes().add(modelType);
-
- modelType.setName(asQuoted(artifactType.getName()));
- modelType.setTypeGuid(artifactType.getGuid());
-
- }
- monitor.worked(calculateWork(workPercentage));
- }
-
- private void populateArtifactTypeInheritance(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
- monitor.setTaskName("Artifact Type Inheritance");
- Collection<ArtifactType> artifactTypes = cache.getArtifactTypeCache().getAll();
- for (ArtifactType artifactType : artifactTypes) {
- checkForCancelledStatus(monitor);
- OseeDsl model = getModelByNamespace(getNamespace(artifactType.getName()));
-
- XArtifactType childType = getArtifactType(model, artifactType.getGuid());
-
- for (ArtifactType oseeSuperType : artifactType.getSuperArtifactTypes()) {
- XArtifactType superModelType = getArtifactType(model, oseeSuperType.getGuid());
- childType.getSuperArtifactTypes().add(superModelType);
- }
- }
- monitor.worked(calculateWork(workPercentage));
- }
-
- private void populateArtifactTypeAttributeTypes(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
- monitor.setTaskName("Artifact Type to Attribute Types");
- Collection<ArtifactType> artifactTypes = cache.getArtifactTypeCache().getAll();
- for (ArtifactType artifactType : artifactTypes) {
- checkForCancelledStatus(monitor);
-
- OseeDsl model = getModelByNamespace(getNamespace(artifactType.getName()));
- XArtifactType modelArtifactType = getArtifactType(model, artifactType.getGuid());
-
- Map<Branch, Collection<AttributeType>> types = artifactType.getLocalAttributeTypes();
- if (types != null) {
- List<XAttributeTypeRef> references = new ArrayList<XAttributeTypeRef>();
- for (Entry<Branch, Collection<AttributeType>> entry : types.entrySet()) {
- Branch branch = entry.getKey();
- Collection<AttributeType> attributeTypes = entry.getValue();
- if (attributeTypes != null) {
- for (AttributeType attributeType : attributeTypes) {
-
- XAttributeTypeRef ref = getFactory().createXAttributeTypeRef();
-
- XAttributeType modelType = getAttributeType(model, attributeType.getGuid());
- if (modelType != null) {
- ref.setValidAttributeType(modelType);
- if (branch != null && !branch.getBranchType().isSystemRootBranch()) {
- ref.setBranchGuid(branch.getGuid());
- }
- references.add(ref);
- }
- }
- }
- }
- modelArtifactType.getValidAttributeTypes().addAll(references);
- }
- }
- monitor.worked(calculateWork(workPercentage));
- }
-
- private void populateRelationTypes(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
- monitor.setTaskName("Relation Types");
- Collection<RelationType> relationTypes = cache.getRelationTypeCache().getAll();
- for (RelationType relationType : relationTypes) {
- checkForCancelledStatus(monitor);
- XRelationType modelType = getFactory().createXRelationType();
-
- OseeDsl model = getModelByNamespace(getNamespace(relationType.getName()));
- model.getRelationTypes().add(modelType);
-
- modelType.setName(asQuoted(relationType.getName()));
- modelType.setTypeGuid(relationType.getGuid());
-
- modelType.setDefaultOrderType(getRelationOrderType(relationType.getDefaultOrderTypeGuid()));
- modelType.setMultiplicity(RelationMultiplicityEnum.getByName(relationType.getMultiplicity().name()));
-
- modelType.setSideAName(relationType.getSideAName());
- modelType.setSideBName(relationType.getSideBName());
-
- modelType.setSideAArtifactType(getArtifactType(model, relationType.getArtifactTypeSideA().getGuid()));
- modelType.setSideBArtifactType(getArtifactType(model, relationType.getArtifactTypeSideB().getGuid()));
- }
- monitor.worked(calculateWork(workPercentage));
- }
-
- private XArtifactType getArtifactType(OseeDsl model, String guid) {
- for (XArtifactType artifactType : model.getArtifactTypes()) {
- if (guid.equals(artifactType.getTypeGuid())) {
- return artifactType;
- }
- }
- return null;
- }
-
- private XAttributeType getAttributeType(OseeDsl model, String guid) {
- for (XAttributeType attributeType : model.getAttributeTypes()) {
- if (guid.equals(attributeType.getTypeGuid())) {
- return attributeType;
- }
- }
- return null;
- }
-
- private String getRelationOrderType(String guid) throws OseeArgumentException {
- RelationOrderBaseTypes type = RelationOrderBaseTypes.getFromGuid(guid);
- return type.getName().replaceAll(" ", "_");
- }
-
- private String asQuoted(String name) {
- return "\"" + name + "\"";
- }
+ private final OseeDsl oseeModel;
+ private final OseeDslFactory factory;
+ private final OseeTypeCache cache;
+
+ public OseeToXtextOperation(OseeTypeCache cache, OseeDslFactory factory, OseeDsl oseeModel) {
+ super("OSEE to Text Model", Activator.PLUGIN_ID);
+ this.oseeModel = oseeModel;
+ this.factory = factory;
+ this.cache = cache;
+ }
+
+ private OseeDslFactory getFactory() {
+ return factory;
+ }
+
+ private OseeDsl getModelByNamespace(String namespace) {
+ return oseeModel;
+ }
+
+ private String getNamespace(String name) {
+ String toReturn = "default";
+ // if (Strings.isValid(name)) {
+ // int index = name.lastIndexOf(".");
+ // if (index > 0) {
+ // toReturn = name.substring(0, index);
+ // }
+ // }
+ return toReturn;
+ }
+
+ private String asPrimitiveType(String name) {
+ return name.replace("org.eclipse.osee.framework.skynet.core.", "");
+ }
+
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ double workPercentage = 1.0 / 6.0;
+ populateEnumTypes(monitor, workPercentage);
+ populateAttributeTypes(monitor, workPercentage);
+ populateArtifactTypes(monitor, workPercentage);
+ populateArtifactTypeInheritance(monitor, workPercentage);
+ populateArtifactTypeAttributeTypes(monitor, workPercentage);
+ populateRelationTypes(monitor, workPercentage);
+ }
+
+ private void populateEnumTypes(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
+ Collection<OseeEnumType> enumTypes = cache.getEnumTypeCache().getAll();
+ for (OseeEnumType enumType : enumTypes) {
+ checkForCancelledStatus(monitor);
+ XOseeEnumType modelType = getFactory().createXOseeEnumType();
+
+ OseeDsl model = getModelByNamespace(getNamespace(enumType.getName()));
+ model.getEnumTypes().add(modelType);
+
+ modelType.setName(asQuoted(enumType.getName()));
+ modelType.setTypeGuid(enumType.getGuid());
+
+ for (OseeEnumEntry entry : enumType.values()) {
+ checkForCancelledStatus(monitor);
+ XOseeEnumEntry entryModelType = getFactory().createXOseeEnumEntry();
+ modelType.getEnumEntries().add(entryModelType);
+
+ entryModelType.setName(asQuoted(entry.getName()));
+ entryModelType.setOrdinal(String.valueOf(entry.ordinal()));
+ }
+ }
+ monitor.worked(calculateWork(workPercentage));
+ }
+
+ private void populateAttributeTypes(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
+ monitor.setTaskName("Attribute Types");
+ Collection<AttributeType> attributeTypes = cache.getAttributeTypeCache().getAll();
+ for (AttributeType attributeType : attributeTypes) {
+ checkForCancelledStatus(monitor);
+ XAttributeType modelType = getFactory().createXAttributeType();
+
+ OseeDsl model = getModelByNamespace(getNamespace(attributeType.getName()));
+ model.getAttributeTypes().add(modelType);
+
+ modelType.setName(asQuoted(attributeType.getName()));
+ modelType.setTypeGuid(attributeType.getGuid());
+ modelType.setBaseAttributeType(asPrimitiveType(attributeType.getBaseAttributeTypeId()));
+ modelType.setDataProvider(asPrimitiveType(attributeType.getAttributeProviderId()));
+ modelType.setMax(String.valueOf(attributeType.getMaxOccurrences()));
+ modelType.setMin(String.valueOf(attributeType.getMinOccurrences()));
+ modelType.setFileExtension(attributeType.getFileTypeExtension());
+ modelType.setDescription(attributeType.getDescription());
+ modelType.setDefaultValue(attributeType.getDefaultValue());
+ modelType.setTaggerId(attributeType.getTaggerId());
+
+ OseeEnumType oseeEnumType = attributeType.getOseeEnumType();
+ if (oseeEnumType != null) {
+ XOseeEnumType enumType = toModelEnumType(model, oseeEnumType);
+ modelType.setEnumType(enumType);
+ }
+ }
+ monitor.worked(calculateWork(workPercentage));
+ }
+
+ private XOseeEnumType toModelEnumType(OseeDsl model, OseeEnumType oseeEnumType) {
+ String guid = oseeEnumType.getGuid();
+ for (XOseeEnumType type : model.getEnumTypes()) {
+ if (guid.equals(type.getTypeGuid())) {
+ return type;
+ }
+ }
+ return null;
+ }
+
+ private void populateArtifactTypes(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
+ monitor.setTaskName("Artifact Types");
+ Collection<ArtifactType> artifactTypes = cache.getArtifactTypeCache().getAll();
+ for (ArtifactType artifactType : artifactTypes) {
+ checkForCancelledStatus(monitor);
+ XArtifactType modelType = getFactory().createXArtifactType();
+
+ OseeDsl model = getModelByNamespace(getNamespace(artifactType.getName()));
+ model.getArtifactTypes().add(modelType);
+
+ modelType.setName(asQuoted(artifactType.getName()));
+ modelType.setTypeGuid(artifactType.getGuid());
+
+ }
+ monitor.worked(calculateWork(workPercentage));
+ }
+
+ private void populateArtifactTypeInheritance(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
+ monitor.setTaskName("Artifact Type Inheritance");
+ Collection<ArtifactType> artifactTypes = cache.getArtifactTypeCache().getAll();
+ for (ArtifactType artifactType : artifactTypes) {
+ checkForCancelledStatus(monitor);
+ OseeDsl model = getModelByNamespace(getNamespace(artifactType.getName()));
+
+ XArtifactType childType = getArtifactType(model, artifactType.getGuid());
+
+ for (ArtifactType oseeSuperType : artifactType.getSuperArtifactTypes()) {
+ XArtifactType superModelType = getArtifactType(model, oseeSuperType.getGuid());
+ childType.getSuperArtifactTypes().add(superModelType);
+ }
+ }
+ monitor.worked(calculateWork(workPercentage));
+ }
+
+ private void populateArtifactTypeAttributeTypes(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
+ monitor.setTaskName("Artifact Type to Attribute Types");
+ Collection<ArtifactType> artifactTypes = cache.getArtifactTypeCache().getAll();
+ for (ArtifactType artifactType : artifactTypes) {
+ checkForCancelledStatus(monitor);
+
+ OseeDsl model = getModelByNamespace(getNamespace(artifactType.getName()));
+ XArtifactType modelArtifactType = getArtifactType(model, artifactType.getGuid());
+
+ Map<Branch, Collection<AttributeType>> types = artifactType.getLocalAttributeTypes();
+ if (types != null) {
+ List<XAttributeTypeRef> references = new ArrayList<XAttributeTypeRef>();
+ for (Entry<Branch, Collection<AttributeType>> entry : types.entrySet()) {
+ Branch branch = entry.getKey();
+ Collection<AttributeType> attributeTypes = entry.getValue();
+ if (attributeTypes != null) {
+ for (AttributeType attributeType : attributeTypes) {
+
+ XAttributeTypeRef ref = getFactory().createXAttributeTypeRef();
+
+ XAttributeType modelType = getAttributeType(model, attributeType.getGuid());
+ if (modelType != null) {
+ ref.setValidAttributeType(modelType);
+ if (branch != null && !branch.getBranchType().isSystemRootBranch()) {
+ ref.setBranchGuid(branch.getGuid());
+ }
+ references.add(ref);
+ }
+ }
+ }
+ }
+ modelArtifactType.getValidAttributeTypes().addAll(references);
+ }
+ }
+ monitor.worked(calculateWork(workPercentage));
+ }
+
+ private void populateRelationTypes(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
+ monitor.setTaskName("Relation Types");
+ Collection<RelationType> relationTypes = cache.getRelationTypeCache().getAll();
+ for (RelationType relationType : relationTypes) {
+ checkForCancelledStatus(monitor);
+ XRelationType modelType = getFactory().createXRelationType();
+
+ OseeDsl model = getModelByNamespace(getNamespace(relationType.getName()));
+ model.getRelationTypes().add(modelType);
+
+ modelType.setName(asQuoted(relationType.getName()));
+ modelType.setTypeGuid(relationType.getGuid());
+
+ modelType.setDefaultOrderType(getRelationOrderType(relationType.getDefaultOrderTypeGuid()));
+ modelType.setMultiplicity(RelationMultiplicityEnum.getByName(relationType.getMultiplicity().name()));
+
+ modelType.setSideAName(relationType.getSideAName());
+ modelType.setSideBName(relationType.getSideBName());
+
+ modelType.setSideAArtifactType(getArtifactType(model, relationType.getArtifactTypeSideA().getGuid()));
+ modelType.setSideBArtifactType(getArtifactType(model, relationType.getArtifactTypeSideB().getGuid()));
+ }
+ monitor.worked(calculateWork(workPercentage));
+ }
+
+ private XArtifactType getArtifactType(OseeDsl model, String guid) {
+ for (XArtifactType artifactType : model.getArtifactTypes()) {
+ if (guid.equals(artifactType.getTypeGuid())) {
+ return artifactType;
+ }
+ }
+ return null;
+ }
+
+ private XAttributeType getAttributeType(OseeDsl model, String guid) {
+ for (XAttributeType attributeType : model.getAttributeTypes()) {
+ if (guid.equals(attributeType.getTypeGuid())) {
+ return attributeType;
+ }
+ }
+ return null;
+ }
+
+ private String getRelationOrderType(String guid) throws OseeArgumentException {
+ RelationOrderBaseTypes type = RelationOrderBaseTypes.getFromGuid(guid);
+ return type.getName().replaceAll(" ", "_");
+ }
+
+ private String asQuoted(String name) {
+ return "\"" + name + "\"";
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeTypeCache.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeTypeCache.java
index e9956a78961..6a91dec2a11 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeTypeCache.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeTypeCache.java
@@ -21,63 +21,63 @@ import org.eclipse.osee.framework.core.model.cache.RelationTypeCache;
*/
public class OseeTypeCache {
- private final ArtifactTypeCache artifactCache;
- private final AttributeTypeCache attributeCache;
- private final RelationTypeCache relationCache;
- private final OseeEnumTypeCache oseeEnumTypeCache;
+ private final ArtifactTypeCache artifactCache;
+ private final AttributeTypeCache attributeCache;
+ private final RelationTypeCache relationCache;
+ private final OseeEnumTypeCache oseeEnumTypeCache;
- private boolean duringPopulate;
+ private boolean duringPopulate;
- public OseeTypeCache(ArtifactTypeCache artifactCache, AttributeTypeCache attributeCache, RelationTypeCache relationCache, OseeEnumTypeCache oseeEnumTypeCache) {
- this.duringPopulate = false;
- this.artifactCache = artifactCache;
- this.attributeCache = attributeCache;
- this.relationCache = relationCache;
- this.oseeEnumTypeCache = oseeEnumTypeCache;
- }
+ public OseeTypeCache(ArtifactTypeCache artifactCache, AttributeTypeCache attributeCache, RelationTypeCache relationCache, OseeEnumTypeCache oseeEnumTypeCache) {
+ this.duringPopulate = false;
+ this.artifactCache = artifactCache;
+ this.attributeCache = attributeCache;
+ this.relationCache = relationCache;
+ this.oseeEnumTypeCache = oseeEnumTypeCache;
+ }
- public void storeAllModified() throws OseeCoreException {
- getEnumTypeCache().storeAllModified();
- getAttributeTypeCache().storeAllModified();
- getArtifactTypeCache().storeAllModified();
- getRelationTypeCache().storeAllModified();
- }
+ public void storeAllModified() throws OseeCoreException {
+ getEnumTypeCache().storeAllModified();
+ getAttributeTypeCache().storeAllModified();
+ getArtifactTypeCache().storeAllModified();
+ getRelationTypeCache().storeAllModified();
+ }
- public synchronized void ensurePopulated() throws OseeCoreException {
- if (!duringPopulate) {
- duringPopulate = true;
- getEnumTypeCache().ensurePopulated();
- getAttributeTypeCache().ensurePopulated();
- getArtifactTypeCache().ensurePopulated();
- getRelationTypeCache().ensurePopulated();
- duringPopulate = false;
- }
- }
+ public synchronized void ensurePopulated() throws OseeCoreException {
+ if (!duringPopulate) {
+ duringPopulate = true;
+ getEnumTypeCache().ensurePopulated();
+ getAttributeTypeCache().ensurePopulated();
+ getArtifactTypeCache().ensurePopulated();
+ getRelationTypeCache().ensurePopulated();
+ duringPopulate = false;
+ }
+ }
- public synchronized void clearAll() {
- if (!duringPopulate) {
- duringPopulate = true;
- getEnumTypeCache().decacheAll();
- getAttributeTypeCache().decacheAll();
- getArtifactTypeCache().decacheAll();
- getRelationTypeCache().decacheAll();
- duringPopulate = false;
- }
- }
+ public synchronized void clearAll() {
+ if (!duringPopulate) {
+ duringPopulate = true;
+ getEnumTypeCache().decacheAll();
+ getAttributeTypeCache().decacheAll();
+ getArtifactTypeCache().decacheAll();
+ getRelationTypeCache().decacheAll();
+ duringPopulate = false;
+ }
+ }
- public ArtifactTypeCache getArtifactTypeCache() {
- return artifactCache;
- }
+ public ArtifactTypeCache getArtifactTypeCache() {
+ return artifactCache;
+ }
- public AttributeTypeCache getAttributeTypeCache() {
- return attributeCache;
- }
+ public AttributeTypeCache getAttributeTypeCache() {
+ return attributeCache;
+ }
- public OseeEnumTypeCache getEnumTypeCache() {
- return oseeEnumTypeCache;
- }
+ public OseeEnumTypeCache getEnumTypeCache() {
+ return oseeEnumTypeCache;
+ }
- public RelationTypeCache getRelationTypeCache() {
- return relationCache;
- }
+ public RelationTypeCache getRelationTypeCache() {
+ return relationCache;
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java
index 8650d26a8b6..fd5944c9a7e 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java
@@ -53,234 +53,234 @@ import org.eclipse.osee.framework.jdk.core.util.Strings;
* @author Roberto E. Escobar
*/
public class XTextToOseeTypeOperation extends AbstractOperation {
- private final IOseeModelFactoryService provider;
- private final OseeDsl model;
- private final OseeTypeCache typeCache;
- private final BranchCache branchCache;
-
- public XTextToOseeTypeOperation(IOseeModelFactoryService provider, OseeTypeCache typeCache, BranchCache branchCache, OseeDsl model) {
- super("OSEE Text Model to OSEE", Activator.PLUGIN_ID);
- this.provider = provider;
- this.typeCache = typeCache;
- this.branchCache = branchCache;
- this.model = model;
- }
-
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- double workAmount = 1.0;
-
- int workTotal = model.getArtifactTypes().size();
- workTotal += model.getAttributeTypes().size();
- workTotal += model.getRelationTypes().size();
- workTotal += model.getEnumTypes().size();
- workTotal += model.getEnumOverrides().size();
-
- if (workTotal > 0) {
- double workPercentage = workAmount / workTotal;
-
- for (XArtifactType xArtifactType : model.getArtifactTypes()) {
- translateXArtifactType(xArtifactType);
- monitor.worked(calculateWork(workPercentage));
- }
-
- for (XOseeEnumOverride xEnumOverride : model.getEnumOverrides()) {
- translateXEnumOverride(xEnumOverride);
- monitor.worked(calculateWork(workPercentage));
- }
-
- for (XOseeEnumType xEnumType : model.getEnumTypes()) {
- translateXEnumType(xEnumType);
- monitor.worked(calculateWork(workPercentage));
- }
-
- for (XAttributeType xAttributeType : model.getAttributeTypes()) {
- translateXAttributeType(xAttributeType);
- monitor.worked(calculateWork(workPercentage));
- }
-
- for (XArtifactType xArtifactType : model.getArtifactTypes()) {
- handleXArtifactTypeCrossRef(xArtifactType);
- monitor.worked(calculateWork(workPercentage));
- }
-
- for (XRelationType xRelationType : model.getRelationTypes()) {
- translateXRelationType(xRelationType);
- monitor.worked(calculateWork(workPercentage));
- }
- }
- }
-
- private void handleXArtifactTypeCrossRef(XArtifactType xArtifactType) throws OseeCoreException {
- ArtifactType targetArtifactType = typeCache.getArtifactTypeCache().getByGuid(xArtifactType.getTypeGuid());
- translateSuperTypes(targetArtifactType, xArtifactType);
- Map<Branch, Collection<AttributeType>> validAttributesPerBranch = getOseeAttributes(xArtifactType);
- targetArtifactType.setAllAttributeTypes(validAttributesPerBranch);
- }
-
- private void translateSuperTypes(ArtifactType targetArtifactType, XArtifactType xArtifactType) throws OseeCoreException {
- Set<ArtifactType> oseeSuperTypes = new HashSet<ArtifactType>();
- for (XArtifactType xSuperType : xArtifactType.getSuperArtifactTypes()) {
- String superTypeName = removeQuotes(xSuperType.getName());
- ArtifactType oseeSuperType = typeCache.getArtifactTypeCache().getUniqueByName(superTypeName);
- oseeSuperTypes.add(oseeSuperType);
- }
-
- if (!oseeSuperTypes.isEmpty()) {
- targetArtifactType.setSuperTypes(oseeSuperTypes);
- }
- }
-
- private Map<Branch, Collection<AttributeType>> getOseeAttributes(XArtifactType xArtifactType) throws OseeCoreException {
- Map<Branch, Collection<AttributeType>> validAttributes = new HashMap<Branch, Collection<AttributeType>>();
- for (XAttributeTypeRef xAttributeTypeRef : xArtifactType.getValidAttributeTypes()) {
- XAttributeType xAttributeType = xAttributeTypeRef.getValidAttributeType();
- Branch branch = getAttributeBranch(xAttributeTypeRef);
- AttributeType oseeAttributeType = typeCache.getAttributeTypeCache().getByGuid(xAttributeType.getTypeGuid());
- if (oseeAttributeType != null) {
- if (validAttributes.get(branch) == null) {
- validAttributes.put(branch, new HashSet<AttributeType>());
- }
- validAttributes.get(branch).add(oseeAttributeType);
- } else {
- System.out.println(String.format("Type was null for \"%s\"", xArtifactType.getName()));
- }
- }
- return validAttributes;
- }
-
- private Branch getAttributeBranch(XAttributeTypeRef xAttributeTypeRef) throws OseeCoreException {
- String branchGuid = xAttributeTypeRef.getBranchGuid();
- if (branchGuid == null || branchCache.getByGuid(branchGuid) == null) {
- return branchCache.getSystemRootBranch();
- } else {
- return branchCache.getByGuid(branchGuid);
- }
- }
-
- private String removeQuotes(String nameReference) {
- return nameReference != null ? nameReference.substring(1, nameReference.length() - 1) : nameReference;
- }
-
- private void translateXArtifactType(XArtifactType xArtifactType) throws OseeCoreException {
- String artifactTypeName = removeQuotes(xArtifactType.getName());
-
- ArtifactType oseeArtifactType =
- provider.getArtifactTypeFactory().createOrUpdate(typeCache.getArtifactTypeCache(),
- xArtifactType.getTypeGuid(), xArtifactType.isAbstract(), artifactTypeName);
- xArtifactType.setTypeGuid(oseeArtifactType.getGuid());
- }
-
- private void translateXEnumType(XOseeEnumType xEnumType) throws OseeCoreException {
- String enumTypeName = removeQuotes(xEnumType.getName());
-
- OseeEnumType oseeEnumType =
- provider.getOseeEnumTypeFactory().createOrUpdate(typeCache.getEnumTypeCache(), xEnumType.getTypeGuid(),
- enumTypeName);
-
- int lastOrdinal = 0;
- List<OseeEnumEntry> oseeEnumEntries = new ArrayList<OseeEnumEntry>();
- for (XOseeEnumEntry xEnumEntry : xEnumType.getEnumEntries()) {
- String entryName = removeQuotes(xEnumEntry.getName());
- String ordinal = xEnumEntry.getOrdinal();
- if (Strings.isValid(ordinal)) {
- lastOrdinal = Integer.parseInt(ordinal);
- }
-
- String entryGuid = xEnumEntry.getEntryGuid();
- oseeEnumEntries.add(provider.getOseeEnumTypeFactory().createEnumEntry(entryGuid, entryName, lastOrdinal));
- lastOrdinal++;
- }
- oseeEnumType.setEntries(oseeEnumEntries);
- }
-
- private void translateXEnumOverride(XOseeEnumOverride xEnumOverride) throws OseeCoreException {
- XOseeEnumType xEnumType = xEnumOverride.getOverridenEnumType();
- if (!xEnumOverride.isInheritAll()) {
- xEnumType.getEnumEntries().clear();
- }
- OseeDslFactory factory = OseeDslFactory.eINSTANCE;
- for (OverrideOption xOverrideOption : xEnumOverride.getOverrideOptions()) {
- if (xOverrideOption instanceof AddEnum) {
- String entryName = ((AddEnum) xOverrideOption).getEnumEntry();
- String entryGuid = ((AddEnum) xOverrideOption).getEntryGuid();
- XOseeEnumEntry xEnumEntry = factory.createXOseeEnumEntry();
- xEnumEntry.setName(entryName);
- xEnumEntry.setEntryGuid(entryGuid);
- xEnumType.getEnumEntries().add(xEnumEntry);
- } else if (xOverrideOption instanceof RemoveEnum) {
- XOseeEnumEntry enumEntry = ((RemoveEnum) xOverrideOption).getEnumEntry();
- xEnumType.getEnumEntries().remove(enumEntry);
- } else {
- throw new OseeStateException("Unsupported Override Operation");
- }
- }
- }
-
- private void translateXAttributeType(XAttributeType xAttributeType) throws OseeCoreException {
- int min = Integer.parseInt(xAttributeType.getMin());
- int max = Integer.MAX_VALUE;
- if (!xAttributeType.getMax().equals("unlimited")) {
- max = Integer.parseInt(xAttributeType.getMax());
- }
- XOseeEnumType xEnumType = xAttributeType.getEnumType();
- OseeEnumType oseeEnumType = null;
- if (xEnumType != null) {
- oseeEnumType = typeCache.getEnumTypeCache().getByGuid(xEnumType.getTypeGuid());
- }
-
- AttributeTypeCache cache = typeCache.getAttributeTypeCache();
- AttributeType oseeAttributeType = provider.getAttributeTypeFactory().createOrUpdate(cache, //
- xAttributeType.getTypeGuid(), //
- removeQuotes(xAttributeType.getName()), //
- getQualifiedTypeName(xAttributeType.getBaseAttributeType()), //
- getQualifiedTypeName(xAttributeType.getDataProvider()), //
- xAttributeType.getFileExtension(), //
- xAttributeType.getDefaultValue(), //
- oseeEnumType, //
- min, //
- max, //
- xAttributeType.getDescription(), //
- xAttributeType.getTaggerId()//
- );
- xAttributeType.setTypeGuid(oseeAttributeType.getGuid());
- }
-
- private String getQualifiedTypeName(String id) {
- String value = id;
- if (!value.contains(".")) {
- value = "org.eclipse.osee.framework.skynet.core." + id;
- }
- return value;
- }
-
- private void translateXRelationType(XRelationType xRelationType) throws OseeCoreException {
- RelationTypeMultiplicity multiplicity =
- RelationTypeMultiplicity.getFromString(xRelationType.getMultiplicity().name());
-
- String sideATypeName = removeQuotes(xRelationType.getSideAArtifactType().getName());
- String sideBTypeName = removeQuotes(xRelationType.getSideBArtifactType().getName());
-
- ArtifactType sideAType = typeCache.getArtifactTypeCache().getUniqueByName(sideATypeName);
- ArtifactType sideBType = typeCache.getArtifactTypeCache().getUniqueByName(sideBTypeName);
-
- RelationType oseeRelationType =
- provider.getRelationTypeFactory().createOrUpdate(typeCache.getRelationTypeCache(), //
- xRelationType.getTypeGuid(), //
- removeQuotes(xRelationType.getName()), //
- xRelationType.getSideAName(), //
- xRelationType.getSideBName(), //
- sideAType, //
- sideBType, //
- multiplicity, //
- convertOrderTypeNameToGuid(xRelationType.getDefaultOrderType()) //
- );
-
- xRelationType.setTypeGuid(oseeRelationType.getGuid());
- }
-
- private String convertOrderTypeNameToGuid(String orderTypeName) throws OseeArgumentException {
- return RelationOrderBaseTypes.getFromOrderTypeName(orderTypeName.replaceAll("_", " ")).getGuid();
- }
+ private final IOseeModelFactoryService provider;
+ private final OseeDsl model;
+ private final OseeTypeCache typeCache;
+ private final BranchCache branchCache;
+
+ public XTextToOseeTypeOperation(IOseeModelFactoryService provider, OseeTypeCache typeCache, BranchCache branchCache, OseeDsl model) {
+ super("OSEE Text Model to OSEE", Activator.PLUGIN_ID);
+ this.provider = provider;
+ this.typeCache = typeCache;
+ this.branchCache = branchCache;
+ this.model = model;
+ }
+
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ double workAmount = 1.0;
+
+ int workTotal = model.getArtifactTypes().size();
+ workTotal += model.getAttributeTypes().size();
+ workTotal += model.getRelationTypes().size();
+ workTotal += model.getEnumTypes().size();
+ workTotal += model.getEnumOverrides().size();
+
+ if (workTotal > 0) {
+ double workPercentage = workAmount / workTotal;
+
+ for (XArtifactType xArtifactType : model.getArtifactTypes()) {
+ translateXArtifactType(xArtifactType);
+ monitor.worked(calculateWork(workPercentage));
+ }
+
+ for (XOseeEnumOverride xEnumOverride : model.getEnumOverrides()) {
+ translateXEnumOverride(xEnumOverride);
+ monitor.worked(calculateWork(workPercentage));
+ }
+
+ for (XOseeEnumType xEnumType : model.getEnumTypes()) {
+ translateXEnumType(xEnumType);
+ monitor.worked(calculateWork(workPercentage));
+ }
+
+ for (XAttributeType xAttributeType : model.getAttributeTypes()) {
+ translateXAttributeType(xAttributeType);
+ monitor.worked(calculateWork(workPercentage));
+ }
+
+ for (XArtifactType xArtifactType : model.getArtifactTypes()) {
+ handleXArtifactTypeCrossRef(xArtifactType);
+ monitor.worked(calculateWork(workPercentage));
+ }
+
+ for (XRelationType xRelationType : model.getRelationTypes()) {
+ translateXRelationType(xRelationType);
+ monitor.worked(calculateWork(workPercentage));
+ }
+ }
+ }
+
+ private void handleXArtifactTypeCrossRef(XArtifactType xArtifactType) throws OseeCoreException {
+ ArtifactType targetArtifactType = typeCache.getArtifactTypeCache().getByGuid(xArtifactType.getTypeGuid());
+ translateSuperTypes(targetArtifactType, xArtifactType);
+ Map<Branch, Collection<AttributeType>> validAttributesPerBranch = getOseeAttributes(xArtifactType);
+ targetArtifactType.setAllAttributeTypes(validAttributesPerBranch);
+ }
+
+ private void translateSuperTypes(ArtifactType targetArtifactType, XArtifactType xArtifactType) throws OseeCoreException {
+ Set<ArtifactType> oseeSuperTypes = new HashSet<ArtifactType>();
+ for (XArtifactType xSuperType : xArtifactType.getSuperArtifactTypes()) {
+ String superTypeName = removeQuotes(xSuperType.getName());
+ ArtifactType oseeSuperType = typeCache.getArtifactTypeCache().getUniqueByName(superTypeName);
+ oseeSuperTypes.add(oseeSuperType);
+ }
+
+ if (!oseeSuperTypes.isEmpty()) {
+ targetArtifactType.setSuperTypes(oseeSuperTypes);
+ }
+ }
+
+ private Map<Branch, Collection<AttributeType>> getOseeAttributes(XArtifactType xArtifactType) throws OseeCoreException {
+ Map<Branch, Collection<AttributeType>> validAttributes = new HashMap<Branch, Collection<AttributeType>>();
+ for (XAttributeTypeRef xAttributeTypeRef : xArtifactType.getValidAttributeTypes()) {
+ XAttributeType xAttributeType = xAttributeTypeRef.getValidAttributeType();
+ Branch branch = getAttributeBranch(xAttributeTypeRef);
+ AttributeType oseeAttributeType = typeCache.getAttributeTypeCache().getByGuid(xAttributeType.getTypeGuid());
+ if (oseeAttributeType != null) {
+ if (validAttributes.get(branch) == null) {
+ validAttributes.put(branch, new HashSet<AttributeType>());
+ }
+ validAttributes.get(branch).add(oseeAttributeType);
+ } else {
+ System.out.println(String.format("Type was null for \"%s\"", xArtifactType.getName()));
+ }
+ }
+ return validAttributes;
+ }
+
+ private Branch getAttributeBranch(XAttributeTypeRef xAttributeTypeRef) throws OseeCoreException {
+ String branchGuid = xAttributeTypeRef.getBranchGuid();
+ if (branchGuid == null || branchCache.getByGuid(branchGuid) == null) {
+ return branchCache.getSystemRootBranch();
+ } else {
+ return branchCache.getByGuid(branchGuid);
+ }
+ }
+
+ private String removeQuotes(String nameReference) {
+ return nameReference != null ? nameReference.substring(1, nameReference.length() - 1) : nameReference;
+ }
+
+ private void translateXArtifactType(XArtifactType xArtifactType) throws OseeCoreException {
+ String artifactTypeName = removeQuotes(xArtifactType.getName());
+
+ ArtifactType oseeArtifactType =
+ provider.getArtifactTypeFactory().createOrUpdate(typeCache.getArtifactTypeCache(),
+ xArtifactType.getTypeGuid(), xArtifactType.isAbstract(), artifactTypeName);
+ xArtifactType.setTypeGuid(oseeArtifactType.getGuid());
+ }
+
+ private void translateXEnumType(XOseeEnumType xEnumType) throws OseeCoreException {
+ String enumTypeName = removeQuotes(xEnumType.getName());
+
+ OseeEnumType oseeEnumType =
+ provider.getOseeEnumTypeFactory().createOrUpdate(typeCache.getEnumTypeCache(), xEnumType.getTypeGuid(),
+ enumTypeName);
+
+ int lastOrdinal = 0;
+ List<OseeEnumEntry> oseeEnumEntries = new ArrayList<OseeEnumEntry>();
+ for (XOseeEnumEntry xEnumEntry : xEnumType.getEnumEntries()) {
+ String entryName = removeQuotes(xEnumEntry.getName());
+ String ordinal = xEnumEntry.getOrdinal();
+ if (Strings.isValid(ordinal)) {
+ lastOrdinal = Integer.parseInt(ordinal);
+ }
+
+ String entryGuid = xEnumEntry.getEntryGuid();
+ oseeEnumEntries.add(provider.getOseeEnumTypeFactory().createEnumEntry(entryGuid, entryName, lastOrdinal));
+ lastOrdinal++;
+ }
+ oseeEnumType.setEntries(oseeEnumEntries);
+ }
+
+ private void translateXEnumOverride(XOseeEnumOverride xEnumOverride) throws OseeCoreException {
+ XOseeEnumType xEnumType = xEnumOverride.getOverridenEnumType();
+ if (!xEnumOverride.isInheritAll()) {
+ xEnumType.getEnumEntries().clear();
+ }
+ OseeDslFactory factory = OseeDslFactory.eINSTANCE;
+ for (OverrideOption xOverrideOption : xEnumOverride.getOverrideOptions()) {
+ if (xOverrideOption instanceof AddEnum) {
+ String entryName = ((AddEnum) xOverrideOption).getEnumEntry();
+ String entryGuid = ((AddEnum) xOverrideOption).getEntryGuid();
+ XOseeEnumEntry xEnumEntry = factory.createXOseeEnumEntry();
+ xEnumEntry.setName(entryName);
+ xEnumEntry.setEntryGuid(entryGuid);
+ xEnumType.getEnumEntries().add(xEnumEntry);
+ } else if (xOverrideOption instanceof RemoveEnum) {
+ XOseeEnumEntry enumEntry = ((RemoveEnum) xOverrideOption).getEnumEntry();
+ xEnumType.getEnumEntries().remove(enumEntry);
+ } else {
+ throw new OseeStateException("Unsupported Override Operation");
+ }
+ }
+ }
+
+ private void translateXAttributeType(XAttributeType xAttributeType) throws OseeCoreException {
+ int min = Integer.parseInt(xAttributeType.getMin());
+ int max = Integer.MAX_VALUE;
+ if (!xAttributeType.getMax().equals("unlimited")) {
+ max = Integer.parseInt(xAttributeType.getMax());
+ }
+ XOseeEnumType xEnumType = xAttributeType.getEnumType();
+ OseeEnumType oseeEnumType = null;
+ if (xEnumType != null) {
+ oseeEnumType = typeCache.getEnumTypeCache().getByGuid(xEnumType.getTypeGuid());
+ }
+
+ AttributeTypeCache cache = typeCache.getAttributeTypeCache();
+ AttributeType oseeAttributeType = provider.getAttributeTypeFactory().createOrUpdate(cache, //
+ xAttributeType.getTypeGuid(), //
+ removeQuotes(xAttributeType.getName()), //
+ getQualifiedTypeName(xAttributeType.getBaseAttributeType()), //
+ getQualifiedTypeName(xAttributeType.getDataProvider()), //
+ xAttributeType.getFileExtension(), //
+ xAttributeType.getDefaultValue(), //
+ oseeEnumType, //
+ min, //
+ max, //
+ xAttributeType.getDescription(), //
+ xAttributeType.getTaggerId()//
+ );
+ xAttributeType.setTypeGuid(oseeAttributeType.getGuid());
+ }
+
+ private String getQualifiedTypeName(String id) {
+ String value = id;
+ if (!value.contains(".")) {
+ value = "org.eclipse.osee.framework.skynet.core." + id;
+ }
+ return value;
+ }
+
+ private void translateXRelationType(XRelationType xRelationType) throws OseeCoreException {
+ RelationTypeMultiplicity multiplicity =
+ RelationTypeMultiplicity.getFromString(xRelationType.getMultiplicity().name());
+
+ String sideATypeName = removeQuotes(xRelationType.getSideAArtifactType().getName());
+ String sideBTypeName = removeQuotes(xRelationType.getSideBArtifactType().getName());
+
+ ArtifactType sideAType = typeCache.getArtifactTypeCache().getUniqueByName(sideATypeName);
+ ArtifactType sideBType = typeCache.getArtifactTypeCache().getUniqueByName(sideBTypeName);
+
+ RelationType oseeRelationType =
+ provider.getRelationTypeFactory().createOrUpdate(typeCache.getRelationTypeCache(), //
+ xRelationType.getTypeGuid(), //
+ removeQuotes(xRelationType.getName()), //
+ xRelationType.getSideAName(), //
+ xRelationType.getSideBName(), //
+ sideAType, //
+ sideBType, //
+ multiplicity, //
+ convertOrderTypeNameToGuid(xRelationType.getDefaultOrderType()) //
+ );
+
+ xRelationType.setTypeGuid(oseeRelationType.getGuid());
+ }
+
+ private String convertOrderTypeNameToGuid(String orderTypeName) throws OseeArgumentException {
+ return RelationOrderBaseTypes.getFromOrderTypeName(orderTypeName.replaceAll("_", " ")).getGuid();
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/Activator.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/Activator.java
index 9a3082dfb65..b6946937c5d 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/Activator.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/Activator.java
@@ -17,18 +17,18 @@ import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
- public static final String PLUGIN_ID = "org.eclipse.osee.framework.core.dsl.integration";
+ public static final String PLUGIN_ID = "org.eclipse.osee.framework.core.dsl.integration";
- private ServiceDependencyTracker dependencyTracker;
+ private ServiceDependencyTracker dependencyTracker;
- @Override
- public void start(BundleContext context) throws Exception {
- dependencyTracker = new ServiceDependencyTracker(context, new OseeModelingServiceRegHandler());
- dependencyTracker.open();
- }
+ @Override
+ public void start(BundleContext context) throws Exception {
+ dependencyTracker = new ServiceDependencyTracker(context, new OseeModelingServiceRegHandler());
+ dependencyTracker.open();
+ }
- @Override
- public void stop(BundleContext context) throws Exception {
- Lib.close(dependencyTracker);
- }
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ Lib.close(dependencyTracker);
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java
index 18f06a7aa20..195a4907ae0 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java
@@ -45,108 +45,107 @@ import org.eclipse.osee.framework.jdk.core.util.Lib;
*/
public class OseeModelingServiceImpl implements IOseeModelingService {
- private final IOseeModelFactoryService modelFactoryService;
- private final IOseeCachingService systemCachingService;
- private final IOseeCachingServiceFactory cachingFactoryService;
- private final OseeDslFactory modelFactory;
-
- public OseeModelingServiceImpl(IOseeModelFactoryService modelFactoryService, IOseeCachingService systemCachingService, IOseeCachingServiceFactory cachingFactoryService, OseeDslFactory dslFactory) {
- this.modelFactoryService = modelFactoryService;
- this.systemCachingService = systemCachingService;
- this.cachingFactoryService = cachingFactoryService;
- this.modelFactory = dslFactory;
-
- }
-
- @Override
- public void exportOseeTypes(IProgressMonitor monitor, OutputStream outputStream) throws OseeCoreException {
- OseeTypeCache cache =
- new OseeTypeCache(systemCachingService.getArtifactTypeCache(),
- systemCachingService.getAttributeTypeCache(), systemCachingService.getRelationTypeCache(),
- systemCachingService.getEnumTypeCache());
-
- OseeDsl model = modelFactory.createOseeDsl();
-
- IOperation operation = new OseeToXtextOperation(cache, modelFactory, model);
- Operations.executeWorkAndCheckStatus(operation, monitor, -1);
- try {
- ModelUtil.saveModel(model, "osee:/oseeTypes_" + Lib.getDateTimeString() + ".osee", outputStream, false);
- } catch (IOException ex) {
- throw new OseeWrappedException(ex);
- }
- }
-
- @Override
- public void importOseeTypes(IProgressMonitor monitor, boolean isInitializing, OseeImportModelRequest request, OseeImportModelResponse response) throws OseeCoreException {
- String modelName = request.getModelName();
- if (!modelName.endsWith(".osee")) {
- modelName += ".osee";
- }
- OseeDsl inputModel = ModelUtil.loadModel("osee:/" + modelName, request.getModel());
-
- IOseeCachingService tempCacheService = cachingFactoryService.createCachingService();
- OseeTypeCache tempCache =
- new OseeTypeCache(tempCacheService.getArtifactTypeCache(), tempCacheService.getAttributeTypeCache(),
- tempCacheService.getRelationTypeCache(), tempCacheService.getEnumTypeCache());
-
- List<TableData> reportData = new ArrayList<TableData>();
- ComparisonResourceSnapshot comparisonSnapshot = DiffFactory.eINSTANCE.createComparisonResourceSnapshot();
- OseeDsl baseModel = modelFactory.createOseeDsl();
- OseeDsl modifiedModel = modelFactory.createOseeDsl();
-
- List<IOperation> ops = new ArrayList<IOperation>();
-
- if (request.isCreateCompareReport()) {
- ops.add(new OseeToXtextOperation(tempCache, modelFactory, baseModel));
- }
-
- ops.add(new XTextToOseeTypeOperation(modelFactoryService, tempCache, tempCacheService.getBranchCache(),
- inputModel));
- if (request.isCreateTypeChangeReport()) {
- ops.add(new CreateOseeTypeChangesReportOperation(tempCache, reportData));
- }
- if (request.isCreateCompareReport()) {
- ops.add(new OseeToXtextOperation(tempCache, modelFactory, baseModel));
- ops.add(new EMFCompareOperation(baseModel, modifiedModel, comparisonSnapshot));
- }
- IOperation operation = new CompositeOperation("Import Osee Types", Activator.PLUGIN_ID, ops);
- Operations.executeWorkAndCheckStatus(operation, monitor, -1);
-
- if (request.isPersistAllowed()) {
- // TODO Make this call transaction based
- tempCache.storeAllModified();
- response.setPersisted(true);
- if (isInitializing) {
- systemCachingService.clearAll();
- }
- systemCachingService.reloadAll();
- } else {
- response.setPersisted(false);
- }
- response.setReportData(reportData);
-
- if (request.isCreateCompareReport()) {
- response.setComparisonSnapshotModelName("osee_compare.diff");
- String modelString =
- ModelUtil.modelToString(comparisonSnapshot, "osee:/osee_compare.diff",
- Collections.<String, Boolean> emptyMap());
- response.setComparisonSnapshotModel(modelString);
- }
- }
- // Map<String, OseeTypeModel> changedModels = new HashMap<String, OseeTypeModel>();
- // doSubWork(new OseeToXtextOperation(modifiedCache, changedModels), monitor, 0.20);
- //
- // OseeTypeCache storeCache = createEmptyCache();
- // storeCache.ensurePopulated();
- // Map<String, OseeTypeModel> baseModels = new HashMap<String, OseeTypeModel>();
- // doSubWork(new OseeToXtextOperation(storeCache, baseModels), monitor, 0.20);
- //
- // OseeTypeModel changedModel = null;
- // OseeTypeModel baseModel = null;
- // for (String key : changedModels.keySet()) {
- // changedModel = changedModels.get(key);
- // baseModel = baseModels.get(key);
- // }
- // }
+ private final IOseeModelFactoryService modelFactoryService;
+ private final IOseeCachingService systemCachingService;
+ private final IOseeCachingServiceFactory cachingFactoryService;
+ private final OseeDslFactory modelFactory;
+
+ public OseeModelingServiceImpl(IOseeModelFactoryService modelFactoryService, IOseeCachingService systemCachingService, IOseeCachingServiceFactory cachingFactoryService, OseeDslFactory dslFactory) {
+ this.modelFactoryService = modelFactoryService;
+ this.systemCachingService = systemCachingService;
+ this.cachingFactoryService = cachingFactoryService;
+ this.modelFactory = dslFactory;
+
+ }
+
+ @Override
+ public void exportOseeTypes(IProgressMonitor monitor, OutputStream outputStream) throws OseeCoreException {
+ OseeTypeCache cache =
+ new OseeTypeCache(systemCachingService.getArtifactTypeCache(), systemCachingService.getAttributeTypeCache(),
+ systemCachingService.getRelationTypeCache(), systemCachingService.getEnumTypeCache());
+
+ OseeDsl model = modelFactory.createOseeDsl();
+
+ IOperation operation = new OseeToXtextOperation(cache, modelFactory, model);
+ Operations.executeWorkAndCheckStatus(operation, monitor, -1);
+ try {
+ ModelUtil.saveModel(model, "osee:/oseeTypes_" + Lib.getDateTimeString() + ".osee", outputStream, false);
+ } catch (IOException ex) {
+ throw new OseeWrappedException(ex);
+ }
+ }
+
+ @Override
+ public void importOseeTypes(IProgressMonitor monitor, boolean isInitializing, OseeImportModelRequest request, OseeImportModelResponse response) throws OseeCoreException {
+ String modelName = request.getModelName();
+ if (!modelName.endsWith(".osee")) {
+ modelName += ".osee";
+ }
+ OseeDsl inputModel = ModelUtil.loadModel("osee:/" + modelName, request.getModel());
+
+ IOseeCachingService tempCacheService = cachingFactoryService.createCachingService();
+ OseeTypeCache tempCache =
+ new OseeTypeCache(tempCacheService.getArtifactTypeCache(), tempCacheService.getAttributeTypeCache(),
+ tempCacheService.getRelationTypeCache(), tempCacheService.getEnumTypeCache());
+
+ List<TableData> reportData = new ArrayList<TableData>();
+ ComparisonResourceSnapshot comparisonSnapshot = DiffFactory.eINSTANCE.createComparisonResourceSnapshot();
+ OseeDsl baseModel = modelFactory.createOseeDsl();
+ OseeDsl modifiedModel = modelFactory.createOseeDsl();
+
+ List<IOperation> ops = new ArrayList<IOperation>();
+
+ if (request.isCreateCompareReport()) {
+ ops.add(new OseeToXtextOperation(tempCache, modelFactory, baseModel));
+ }
+
+ ops.add(new XTextToOseeTypeOperation(modelFactoryService, tempCache, tempCacheService.getBranchCache(),
+ inputModel));
+ if (request.isCreateTypeChangeReport()) {
+ ops.add(new CreateOseeTypeChangesReportOperation(tempCache, reportData));
+ }
+ if (request.isCreateCompareReport()) {
+ ops.add(new OseeToXtextOperation(tempCache, modelFactory, baseModel));
+ ops.add(new EMFCompareOperation(baseModel, modifiedModel, comparisonSnapshot));
+ }
+ IOperation operation = new CompositeOperation("Import Osee Types", Activator.PLUGIN_ID, ops);
+ Operations.executeWorkAndCheckStatus(operation, monitor, -1);
+
+ if (request.isPersistAllowed()) {
+ // TODO Make this call transaction based
+ tempCache.storeAllModified();
+ response.setPersisted(true);
+ if (isInitializing) {
+ systemCachingService.clearAll();
+ }
+ systemCachingService.reloadAll();
+ } else {
+ response.setPersisted(false);
+ }
+ response.setReportData(reportData);
+
+ if (request.isCreateCompareReport()) {
+ response.setComparisonSnapshotModelName("osee_compare.diff");
+ String modelString =
+ ModelUtil.modelToString(comparisonSnapshot, "osee:/osee_compare.diff",
+ Collections.<String, Boolean> emptyMap());
+ response.setComparisonSnapshotModel(modelString);
+ }
+ }
+ // Map<String, OseeTypeModel> changedModels = new HashMap<String, OseeTypeModel>();
+ // doSubWork(new OseeToXtextOperation(modifiedCache, changedModels), monitor, 0.20);
+ //
+ // OseeTypeCache storeCache = createEmptyCache();
+ // storeCache.ensurePopulated();
+ // Map<String, OseeTypeModel> baseModels = new HashMap<String, OseeTypeModel>();
+ // doSubWork(new OseeToXtextOperation(storeCache, baseModels), monitor, 0.20);
+ //
+ // OseeTypeModel changedModel = null;
+ // OseeTypeModel baseModel = null;
+ // for (String key : changedModels.keySet()) {
+ // changedModel = changedModels.get(key);
+ // baseModel = baseModels.get(key);
+ // }
+ // }
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceRegHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceRegHandler.java
index 537c5097217..73bbd73ed4a 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceRegHandler.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceRegHandler.java
@@ -25,37 +25,37 @@ import org.osgi.framework.ServiceRegistration;
*/
public class OseeModelingServiceRegHandler extends AbstractTrackingHandler {
- private static final Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {
- //
- IOseeCachingService.class, //
- IOseeModelFactoryService.class, //
- IOseeCachingServiceFactory.class //
- };
-
- private ServiceRegistration registration;
-
- @Override
- public Class<?>[] getDependencies() {
- return SERVICE_DEPENDENCIES;
- }
-
- @Override
- public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
- IOseeModelFactoryService modelFactoryService = getService(IOseeModelFactoryService.class, services);
- IOseeCachingService cachingService = getService(IOseeCachingService.class, services);
- IOseeCachingServiceFactory cachingFactoryService = getService(IOseeCachingServiceFactory.class, services);
-
- IOseeModelingService service =
- new OseeModelingServiceImpl(modelFactoryService, cachingService, cachingFactoryService,
- OseeDslFactory.eINSTANCE);
- registration = context.registerService(IOseeModelingService.class.getName(), service, null);
- }
-
- @Override
- public void onDeActivate() {
- if (registration != null) {
- registration.unregister();
- }
- }
+ private static final Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {
+ //
+ IOseeCachingService.class, //
+ IOseeModelFactoryService.class, //
+ IOseeCachingServiceFactory.class //
+ };
+
+ private ServiceRegistration registration;
+
+ @Override
+ public Class<?>[] getDependencies() {
+ return SERVICE_DEPENDENCIES;
+ }
+
+ @Override
+ public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
+ IOseeModelFactoryService modelFactoryService = getService(IOseeModelFactoryService.class, services);
+ IOseeCachingService cachingService = getService(IOseeCachingService.class, services);
+ IOseeCachingServiceFactory cachingFactoryService = getService(IOseeCachingServiceFactory.class, services);
+
+ IOseeModelingService service =
+ new OseeModelingServiceImpl(modelFactoryService, cachingService, cachingFactoryService,
+ OseeDslFactory.eINSTANCE);
+ registration = context.registerService(IOseeModelingService.class.getName(), service, null);
+ }
+
+ @Override
+ public void onDeActivate() {
+ if (registration != null) {
+ registration.unregister();
+ }
+ }
}

Back to the top