Skip to content
Snippets Groups Projects
Commit 170f632e authored by Konstantin Blaschke's avatar Konstantin Blaschke
Browse files

# WARNING: head commit changed in the meantime

Setting up Metric extraction plugin for AF3
Issue-Ref: 4310
Issue-Url: af3#4310


Signed-off-by: default avatarKonstantin Blaschke <blaschke@fortiss.org>
parent 7830d1e7
No related branches found
No related tags found
1 merge request!210Setting up Metric extraction plugin for AF3 : Issue 4310
......@@ -5,3 +5,13 @@ Bundle-SymbolicName: org.fortiss.tooling.ext.quality
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: org.fortiss.tooling.ext.quality
Bundle-RequiredExecutionEnvironment: JavaSE-11
Import-Package: org.eclipse.core.runtime;version="3.5.0",
org.eclipse.emf.ecore,
org.eclipse.emf.ecore.xml.type,
org.fortiss.tooling.kernel.extension.data,
org.fortiss.tooling.kernel.introspection,
org.fortiss.tooling.kernel.service,
org.fortiss.tooling.kernel.service.base,
org.fortiss.tooling.kernel.utils,
org.osgi.framework
Export-Package: org.fortiss.tooling.ext.quality.service
package org.fortiss.tooling.ext.quality;
/*-------------------------------------------------------------------------+
| Copyright 2023 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle.
*
* @author blaschke
*/
public class AF3QualityActivator extends Plugin {
/** The plug-in ID. */
public static final String PLUGIN_ID = AF3QualityActivator.class.getPackage().getName(); // $NON-NLS-1$
/** The shared instance. */
private static AF3QualityActivator plugin;
/** {@inheritDoc} */
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
System.out.println("[Plugin] " + PLUGIN_ID + " started.");
}
/** {@inheritDoc} */
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/** Returns the shared instance. */
public static AF3QualityActivator getDefault() {
return plugin;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2011 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.ext.quality.service;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.base.IObjectAware;
/**
* Interface for the migration provider implementations.
* <P>
* migration provider extensions are handled by {@link IMetricService}.
*
* @author blaschke
*/
public interface IMetricProvider extends IObjectAware<ITopLevelElement> {
/**
* Determines whether migration provider is needed for the given
* model element.
*
* The parameter "unknownFeatures" returns a map indicating the features that are not recognized
* in the model. This can be useful to detect features coming from old models and can be then
* translated to the new model by a migrator.
*/
boolean needMigration(ITopLevelElement modelElement, Map<EObject, AnyType> unknownFeatures);
/**
* Applies the provider to the given element.
*
* The parameter "unknownFeatures" indicates the features that are not recognized
* in the model. This can be useful to detect features coming from old models and can be then
* translated to the new model by a migrator.
*
* @return all unknown features that have successfully been migrated.
*/
Map<EObject, AnyType> migrate(ITopLevelElement modelElement,
Map<EObject, AnyType> unknownFeatures);
}
\ No newline at end of file
/*-------------------------------------------------------------------------+
| Copyright 2011 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.ext.quality.service;
/**
* The migration service checks and upgrades the old models from the last release.
*
* @author mou
*/
public interface IMetricService {
/** Returns the service instance. */
public static IMetricService getInstance() {
return MetricService.getInstance();
}
/** Registers the metric provider with the service. */
void registerMetricProvider(IMetricProvider provider, Class<?> modelElementClass);
}
/*-------------------------------------------------------------------------+
| Copyright 2013 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.ext.quality.service;
import static java.util.Collections.emptyList;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstChildWithType;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
import org.fortiss.tooling.kernel.service.IKernelIntrospectionSystemService;
import org.fortiss.tooling.kernel.service.IMigrationService;
import org.fortiss.tooling.kernel.service.base.ObjectAwareServiceBase;
/**
* This class implements the {@link IMigrationService} interface.
*
* @author blaschke
*/
public class MetricService extends ObjectAwareServiceBase<IMetricProvider> implements IIntrospectiveKernelService, IMetricService{
/** The singleton instance. */
private static final MetricService INSTANCE = new MetricService();
/** Returns singleton instance of the service. */
public static MetricService getInstance() {
return INSTANCE;
}
/** The connector extension point ID. */
private static final String EXTENSION_POINT_NAME =
"org.fortiss.tooling.ext.quality.metricService";
/** The connector configuration element name. */
private static final String CONFIGURATION_ELEMENT_NAME = "metricService";
/** The connector attribute name. */
private static final String ATTRIBUTE_NAME = "metricService";
/** */
@Override
public void startService() {
IKernelIntrospectionSystemService.getInstance().registerService(this);
}
/** Registers the migration provider with the service. */
@Override
public void registerMetricProvider(IMetricProvider provider, Class<?> modelElementClass) {
addHandler(modelElementClass, provider);
}
/** {@inheritDoc} */
@Override
public String getIntrospectionDescription() {
return getIntrospectionLabel() +
"\n\nThis service allows the tracking of metrical development in modeling." +
"\n the service outputs the current metric analysis of the model and stores" +
"\n the data within logs for later history analysis." +
"\n\nThe service extension point is '" + EXTENSION_POINT_NAME + "'.";
}
/** Get all suitable {@link IMetricProvider} for the given input. */
@SuppressWarnings("unused")
private List<IMetricProvider> getProviders(ITopLevelElement input) {
List<IMetricProvider> providers = new ArrayList<>();
EObject migElement = input.getRootModelElement();
for(Entry<Class<?>, List<IMetricProvider>> migEntry : handlerMap.entrySet()) {
if(getFirstChildWithType(migElement, migEntry.getKey()) != null) {
providers.addAll(migEntry.getValue());
}
}
return providers;
}
/** */
@Override
protected String getExtensionPointName() {
return EXTENSION_POINT_NAME;
}
/** */
@Override
protected String getConfigurationElementName() {
return CONFIGURATION_ELEMENT_NAME;
}
/** */
@Override
protected String getHandlerClassAttribute() {
return ATTRIBUTE_NAME;
}
/** {@inheritDoc} */
@Override
public String getIntrospectionLabel() {
return "Metric Service";
}
/** {@inheritDoc} */
@Override
public List<IIntrospectionItem> getIntrospectionItems() {
return emptyList();
}
/** {@inheritDoc} */
@Override
public boolean showInIntrospectionNavigation() {
return true;
}
@SuppressWarnings("javadoc")
@Override
public IIntrospectionDetailsItem getDetailsItem() {
return null;
}
}
......@@ -41,4 +41,5 @@ Export-Package: org.fortiss.tooling.kernel; uses:="org.eclipse.core.runtime,
org.fortiss.tooling.kernel.utils; uses:="org.eclipse.emf.ecore,
org.eclipse.core.resources"
Automatic-Module-Name: org.fortiss.tooling.kernel
Import-Package: com.google.common.collect
Import-Package: com.google.common.collect,
org.fortiss.tooling.ext.quality.service
......@@ -17,6 +17,7 @@ package org.fortiss.tooling.kernel.internal;
import static org.fortiss.tooling.kernel.ToolingKernel.printPhase;
import org.fortiss.tooling.ext.quality.service.MetricService;
import org.fortiss.tooling.kernel.internal.storage.eclipse.EclipseResourceStorageService;
/**
......@@ -42,6 +43,7 @@ public final class ToolingKernelInternal {
PrototypeService.getInstance().initializeService();
TransformationService.getInstance().initializeService();
TutorialService.getInstance().initializeService();
MetricService.getInstance().initializeService();
printPhase("Tooling Kernel initialized.");
}
......@@ -60,6 +62,7 @@ public final class ToolingKernelInternal {
PersistencyService.getInstance().startService();
PrototypeService.getInstance().startService();
TransformationService.getInstance().startService();
MetricService.getInstance().startService();
printPhase("Tooling Kernel started.");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment