Skip to content
Snippets Groups Projects
Commit 7a920327 authored by Cheng Zhang's avatar Cheng Zhang
Browse files

fix generation error when generate test suite from specification

fix repeated coverage analysis error
add no id migration process
refs 1801
parent a10150b8
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="IModelElementSpecification" abstract="true"
interface="true">
interface="true" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//IIdLabeled">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Super class of model element specifications. Such specifications provide additional plugable properties."/>
</eAnnotations>
......
......@@ -26,4 +26,13 @@
uri="http://www.fortiss.org/tooling/base/model/base">
</package>
</extension>
<extension
point="org.fortiss.tooling.kernel.migrationProvider">
<migrationProvider
migrationProvider="org.fortiss.tooling.base.migration.IDMigrationProvider">
<objectClass
objectClass="org.fortiss.tooling.kernel.extension.data.ITopLevelElement">
</objectClass>
</migrationProvider>
</extension>
</plugin>
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| 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.base.migration;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.hasMissingIDs;
import org.fortiss.tooling.kernel.extension.IMigrationProvider;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.utils.UniqueIDUtils;
/**
*
* @author Shaka
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public class IDMigrationProvider implements IMigrationProvider {
/** {@inheritDoc} */
@Override
public boolean needMigration(ITopLevelElement modelElement) {
// if the id of model element is 0
if(modelElement != null && modelElement.getRootModelElement() != null &&
hasMissingIDs(modelElement.getRootModelElement())) {
return true;
}
return false;
}
/** {@inheritDoc} */
@Override
public void migrate(ITopLevelElement modelElement) {
UniqueIDUtils.fixMissingIDs(modelElement);
}
}
......@@ -202,4 +202,41 @@ public class UniqueIDUtils {
}
}
}
/**
* verify whether there is missing id.
* if it is existing, return the max id. Otherwise return 0.
*
* @param existingModel
* top level element
*/
public static boolean hasMissingIDs(EObject existingModel) {
for(Iterator<EObject> i = existingModel.eAllContents(); i.hasNext();) {
EObject eo = i.next();
if(eo instanceof IIdLabeled) {
if(((IIdLabeled)eo).getId() <= 0) {
return true;
}
}
}
return false;
}
/**
* Generates all missing IDs of the given model.
*
* @param modelElement
* top level element
*/
public static void fixMissingIDs(final ITopLevelElement modelElement) {
final int maxID = getLargestID(modelElement.getRootModelElement());
if(maxID > 0) {
modelElement.runAsCommand(new Runnable() {
@Override
public void run() {
generateMissingIDs(modelElement.getRootModelElement(), maxID);
}
});
}
}
}
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