diff options
author | rescobar | 2010-07-22 23:21:24 +0000 |
---|---|---|
committer | rescobar | 2010-07-22 23:21:24 +0000 |
commit | 291eb5536c4c8a42c0eaebcbb61939bc2cf0ad93 (patch) | |
tree | 9e738f62ed2ace02337fd3da7460aa3141e01903 | |
parent | d311fe95d6d014a775fa5aa773b7e1f2eb825248 (diff) | |
download | org.eclipse.osee-291eb5536c4c8a42c0eaebcbb61939bc2cf0ad93.tar.gz org.eclipse.osee-291eb5536c4c8a42c0eaebcbb61939bc2cf0ad93.tar.xz org.eclipse.osee-291eb5536c4c8a42c0eaebcbb61939bc2cf0ad93.zip |
Core Dsl Updates for Access Control
4 files changed, 244 insertions, 6 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core.dsl.integration/META-INF/MANIFEST.MF index 5f9bf02ac69..edc6fe674be 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/META-INF/MANIFEST.MF @@ -21,7 +21,9 @@ Import-Package: org.eclipse.core.runtime, org.eclipse.osee.framework.core.operation, org.eclipse.osee.framework.core.services, org.eclipse.osee.framework.core.util, - org.eclipse.osee.framework.jdk.core.util + org.eclipse.osee.framework.jdk.core.util, + org.osgi.framework, + org.osgi.util.tracker Require-Bundle: org.eclipse.osee.framework.core.dsl, org.eclipse.emf.ecore, org.eclipse.emf.common, 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 a3f742284c9..9a3082dfb65 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 @@ -1,11 +1,34 @@ -/* - * Created on Jul 22, 2010 +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE - */ + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ package org.eclipse.osee.framework.core.dsl.integration.internal; -public class Activator { +import org.eclipse.osee.framework.core.util.ServiceDependencyTracker; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { public static final String PLUGIN_ID = "org.eclipse.osee.framework.core.dsl.integration"; + + private ServiceDependencyTracker dependencyTracker; + + @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); + } } 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 new file mode 100644 index 00000000000..18f06a7aa20 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java @@ -0,0 +1,152 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.core.dsl.integration.internal; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSnapshot; +import org.eclipse.emf.compare.diff.metamodel.DiffFactory; +import org.eclipse.osee.framework.core.dsl.integration.CreateOseeTypeChangesReportOperation; +import org.eclipse.osee.framework.core.dsl.integration.EMFCompareOperation; +import org.eclipse.osee.framework.core.dsl.integration.ModelUtil; +import org.eclipse.osee.framework.core.dsl.integration.OseeToXtextOperation; +import org.eclipse.osee.framework.core.dsl.integration.OseeTypeCache; +import org.eclipse.osee.framework.core.dsl.integration.XTextToOseeTypeOperation; +import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl; +import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDslFactory; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.exception.OseeWrappedException; +import org.eclipse.osee.framework.core.message.IOseeModelingService; +import org.eclipse.osee.framework.core.message.OseeImportModelRequest; +import org.eclipse.osee.framework.core.message.OseeImportModelResponse; +import org.eclipse.osee.framework.core.message.TableData; +import org.eclipse.osee.framework.core.operation.CompositeOperation; +import org.eclipse.osee.framework.core.operation.IOperation; +import org.eclipse.osee.framework.core.operation.Operations; +import org.eclipse.osee.framework.core.services.IOseeCachingService; +import org.eclipse.osee.framework.core.services.IOseeCachingServiceFactory; +import org.eclipse.osee.framework.core.services.IOseeModelFactoryService; +import org.eclipse.osee.framework.jdk.core.util.Lib; + +/** + * @author Roberto E. Escobar + */ +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); + // } + // } + +} 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 new file mode 100644 index 00000000000..537c5097217 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceRegHandler.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.core.dsl.integration.internal; + +import java.util.Map; +import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDslFactory; +import org.eclipse.osee.framework.core.message.IOseeModelingService; +import org.eclipse.osee.framework.core.services.IOseeCachingService; +import org.eclipse.osee.framework.core.services.IOseeCachingServiceFactory; +import org.eclipse.osee.framework.core.services.IOseeModelFactoryService; +import org.eclipse.osee.framework.core.util.AbstractTrackingHandler; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +/** + * @author Roberto E. Escobar + */ +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(); + } + } + +} |