Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2015-02-10 10:53:53 +0000
committerptessier2015-02-10 10:53:53 +0000
commitc2a3413d5284b8243491aa4aa6abdb2e6de5898a (patch)
treec64370b2f831cb0ba48c174a9c3e4cd6b9a49574
parent6dd61905974abd1e89ff82dc1310972d6ef11c3c (diff)
downloadorg.eclipse.papyrus-c2a3413d5284b8243491aa4aa6abdb2e6de5898a.tar.gz
org.eclipse.papyrus-c2a3413d5284b8243491aa4aa6abdb2e6de5898a.tar.xz
org.eclipse.papyrus-c2a3413d5284b8243491aa4aa6abdb2e6de5898a.zip
# WARNING: head commit changed in the meantime
447870: [Papyrus Req] Papyrus shall import or export reqIF file https://bugs.eclipse.org/bugs/show_bug.cgi?id=447870 Merge branch 'master' of ssh://ptessier@git.eclipse.org:29418/papyrus/org.eclipse.papyrus Change-Id: I292c16f9f160ff0f90b6595b6abd79ec50a6756a
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.reqif/src/org/eclipse/papyrus/req/reqif/integration/transformation/ReqIFImporterServiceEdit.java9
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.reqif/src/org/eclipse/papyrus/req/reqif/transformation/ReqIFImporter.java292
m---------tests/recipes/extraplugins/uml/org.eclipse.papyrus.req.reqif.test0
3 files changed, 175 insertions, 126 deletions
diff --git a/extraplugins/req/org.eclipse.papyrus.req.reqif/src/org/eclipse/papyrus/req/reqif/integration/transformation/ReqIFImporterServiceEdit.java b/extraplugins/req/org.eclipse.papyrus.req.reqif/src/org/eclipse/papyrus/req/reqif/integration/transformation/ReqIFImporterServiceEdit.java
index a2967471ece..603d191061b 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.reqif/src/org/eclipse/papyrus/req/reqif/integration/transformation/ReqIFImporterServiceEdit.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.reqif/src/org/eclipse/papyrus/req/reqif/integration/transformation/ReqIFImporterServiceEdit.java
@@ -31,6 +31,7 @@ import org.eclipse.papyrus.req.reqif.integration.assistant.ChooseReqIFTypeDialog
import org.eclipse.papyrus.req.reqif.integration.command.DefineProfileCommand;
import org.eclipse.papyrus.req.reqif.transformation.ReqIFImporter;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
import org.eclipse.rmf.reqif10.ReqIF;
import org.eclipse.rmf.reqif10.SpecType;
import org.eclipse.swt.widgets.Shell;
@@ -64,17 +65,19 @@ public class ReqIFImporterServiceEdit extends ReqIFImporter {
* @see org.eclipse.papyrus.req.reqif.transformation.ReqIFImporter#createRequirementClass(org.eclipse.uml2.uml.Element)
*{@inheritDoc}
*/
- protected Class createRequirementClass(org.eclipse.uml2.uml.Element owner) {
+ protected Class createClassWithRequirementName(org.eclipse.uml2.uml.Element owner) {
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(owner);
if(provider == null) {
return null;
}
- ICommand createGMFCommand = provider.getEditCommand(new CreateElementRequest(domain, owner, SysMLElementTypes.REQUIREMENT));
+ ICommand createGMFCommand = provider.getEditCommand(new CreateElementRequest(domain, owner, UMLElementTypes.CLASS));
if(createGMFCommand != null) {
Command emfCommand = new org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper(createGMFCommand);
domain.getCommandStack().execute(emfCommand);
- return (Class)createGMFCommand.getCommandResult().getReturnValue();
+ Class theClass= (Class)createGMFCommand.getCommandResult().getReturnValue();
+ theClass.setName(theClass.getName().replaceAll("Class", "Requirement"));
+ return theClass;
}
return null;
}
diff --git a/extraplugins/req/org.eclipse.papyrus.req.reqif/src/org/eclipse/papyrus/req/reqif/transformation/ReqIFImporter.java b/extraplugins/req/org.eclipse.papyrus.req.reqif/src/org/eclipse/papyrus/req/reqif/transformation/ReqIFImporter.java
index fee8287d480..24e58cabdb2 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.reqif/src/org/eclipse/papyrus/req/reqif/transformation/ReqIFImporter.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.reqif/src/org/eclipse/papyrus/req/reqif/transformation/ReqIFImporter.java
@@ -73,7 +73,8 @@ import org.eclipse.rmf.reqif10.Specification;
import org.eclipse.rmf.reqif10.SpecificationType;
import org.eclipse.rmf.reqif10.XhtmlContent;
import org.eclipse.rmf.reqif10.common.util.ReqIF10Util;
-import org.eclipse.rmf.reqif10.pror.util.ProrUtil;
+import org.eclipse.rmf.reqif10.common.util.ReqIF10XhtmlUtil;
+import org.eclipse.rmf.reqif10.pror.util.ProrXhtmlSimplifiedHelper;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Comment;
@@ -172,7 +173,6 @@ public abstract class ReqIFImporter extends ReqIFBaseTransformation {
specObject.setIdentifier(""+((AttributeValueInteger)attributeValue).getTheValue());
}
}
-
}
}
}
@@ -248,6 +248,31 @@ public abstract class ReqIFImporter extends ReqIFBaseTransformation {
return value;
}
}
+
+ //maybe it has a default value in the definition.
+ if( attributeDefinition instanceof AttributeDefinitionEnumeration){
+ return ((AttributeDefinitionEnumeration)attributeDefinition).getDefaultValue();
+ }
+ //maybe it has a default value in the definition.
+ if( attributeDefinition instanceof AttributeDefinitionBoolean){
+ return ((AttributeDefinitionBoolean)attributeDefinition).getDefaultValue();
+ }
+ //maybe it has a default value in the definition.
+ if( attributeDefinition instanceof AttributeDefinitionInteger){
+ return ((AttributeDefinitionInteger)attributeDefinition).getDefaultValue();
+ }
+ //maybe it has a default value in the definition.
+ if( attributeDefinition instanceof AttributeDefinitionReal){
+ return ((AttributeDefinitionReal)attributeDefinition).getDefaultValue();
+ }
+ //maybe it has a default value in the definition.
+ if( attributeDefinition instanceof AttributeDefinitionString){
+ return ((AttributeDefinitionString)attributeDefinition).getDefaultValue();
+ }
+ //maybe it has a default value in the definition.
+ if( attributeDefinition instanceof AttributeDefinitionXHTML){
+ return ((AttributeDefinitionXHTML)attributeDefinition).getDefaultValue();
+ }
return null;
}
@@ -311,7 +336,7 @@ public abstract class ReqIFImporter extends ReqIFBaseTransformation {
}
else{
//SIMPLE USER choose profiles
-
+
//popose a list of profile from registered profiles
List<IRegisteredProfile> registeredProfiles=RegisteredProfile.getRegisteredProfiles();
ArrayList<Profile> profilelist= new ArrayList<Profile>();
@@ -319,7 +344,8 @@ public abstract class ReqIFImporter extends ReqIFBaseTransformation {
IRegisteredProfile iRegisteredProfile = (IRegisteredProfile) iterator.next();
ResourceSet resourceSet = UMLModel.eResource().getResourceSet();
Resource resource=resourceSet.getResource(iRegisteredProfile.getUri(), true);
- if( resource.getContents().get(0) instanceof Profile){
+
+ if(resource.getContents().size()==1 && resource.getContents().get(0) instanceof Profile){
profilelist.add((Profile)resource.getContents().get(0));
}
@@ -337,7 +363,7 @@ public abstract class ReqIFImporter extends ReqIFBaseTransformation {
}
UMLModel.applyProfile(profileToApply);
-
+
//getAll stereotypes that represents types in profiles
getAllStereotypesRepresentingTypes(UMLModel);
specObjectTypesToCreate= new ArrayList<SpecType>();
@@ -350,10 +376,10 @@ public abstract class ReqIFImporter extends ReqIFBaseTransformation {
specRelationTypesToCreate,
dataTypeDefinitionToCreate);
if( specObjectTypesToCreate.size()>0||specificationTypesToCreate.size()>0||specRelationTypesToCreate.size()>0||dataTypeDefinitionToCreate.size()>0){
-
+
createMessageForTypewithoutStereotypes(specObjectTypesToCreate, specificationTypesToCreate,
specRelationTypesToCreate, dataTypeDefinitionToCreate);
-
+
return false;
}
}
@@ -627,135 +653,153 @@ public abstract class ReqIFImporter extends ReqIFBaseTransformation {
* @param specType the type of the SpecElementWithAttributes
*/
protected void importSpecAttributesValue(HashMap<String, Stereotype> reqStereotypesMap, SpecElementWithAttributes specif, Element umlElement, SpecType specType) {
- for(AttributeValue att : specif.getValues()) {
-
-
- if(att instanceof AttributeValueString){
- String attributeName=((AttributeValueString)att).getDefinition().getLongName().trim();
- attributeName = getNormalName(attributeName);
- Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
- if( stereotype!=null){
- Property aProperty=getProperty(stereotype, attributeName);
- if(aProperty!=null){
- umlElement.setValue(
- reqStereotypesMap.get(specType.getLongName()),
- attributeName,
- ((AttributeValueString)att).getTheValue());
- if( attributeName.equals("ID")){
- if(umlElement instanceof NamedElement){
- ((NamedElement)umlElement).setName(((AttributeValueString)att).getTheValue());
+ if(specType!=null){
+ for (AttributeDefinition attDefinition : specType.getSpecAttributes()) {
+ AttributeValue att=getAttributeValue(specif, attDefinition);
+ if( att!=null){
+ if(att instanceof AttributeValueString){
+ String attributeName=((AttributeValueString)att).getDefinition().getLongName().trim();
+ attributeName = getNormalName(attributeName);
+ Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
+ if( stereotype!=null){
+ Property aProperty=getProperty(stereotype, attributeName);
+ if(aProperty!=null){
+ umlElement.setValue(
+ reqStereotypesMap.get(specType.getLongName()),
+ attributeName,
+ ((AttributeValueString)att).getTheValue());
+ if( attributeName.equals("ID")){
+ if(umlElement instanceof NamedElement){
+ ((NamedElement)umlElement).setName(((AttributeValueString)att).getTheValue());
+ }
+ }
}
}
}
- }
- }
- if(att instanceof AttributeValueBoolean){
- String attributeName=((AttributeValueBoolean)att).getDefinition().getLongName().trim();
- attributeName = getNormalName(attributeName);
- Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
- if( stereotype!=null){
- Property aProperty=getProperty(stereotype, attributeName);
- if(aProperty!=null){
- umlElement.setValue(
- reqStereotypesMap.get(specType.getLongName()),
- attributeName,
- ((AttributeValueBoolean)att).isTheValue());
- }
- }
- }
- if(att instanceof AttributeValueInteger){
- String attributeName=((AttributeValueInteger)att).getDefinition().getLongName().trim();
- attributeName = getNormalName(attributeName);
- Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
- if( stereotype!=null){
- Property aProperty=getProperty(stereotype, attributeName);
- if(aProperty!=null){
- umlElement.setValue(
- reqStereotypesMap.get(specType.getLongName()),
- attributeName,
- ((AttributeValueInteger)att).getTheValue().intValue());
- }
- }
- }
- if(att instanceof AttributeValueReal){
- String attributeName=((AttributeValueReal)att).getDefinition().getLongName().trim();
- attributeName = getNormalName(attributeName);
- Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
- if( stereotype!=null){
- Property aProperty=getProperty(stereotype, attributeName);
- if(aProperty!=null){
- umlElement.setValue(
- reqStereotypesMap.get(specType.getLongName()),
- attributeName,
- ((AttributeValueReal)att).getTheValue());
- }
- }
- }
- if(att instanceof AttributeValueEnumeration){
- String attributeName=((AttributeValueEnumeration)att).getDefinition().getLongName().trim();
- attributeName = getNormalName(attributeName);
- Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
- if( stereotype!=null){
- Property aProperty=getProperty(stereotype, attributeName);
- if(aProperty!=null){
- if(((AttributeValueEnumeration)att).getValues().size()>0){
- String EnumerationValue=getNormalName(((AttributeValueEnumeration)att).getValues().get(0).getLongName());
- //look for Enumeration literal
- Enumeration aEnumeration= null;
- //look for attribute
- Stereotype referedStereotype= reqStereotypesMap.get(specType.getLongName());
- Property referedAttribute=null;
- for(Property property:referedStereotype.getAllAttributes()){
- if(property.getName().equals(attributeName)){
- referedAttribute=property;
- }
- }
- aEnumeration= (Enumeration)referedAttribute.getType();
- EnumerationLiteral aEnumerationLiteral=null;
- for(EnumerationLiteral aLiteral:aEnumeration.getOwnedLiterals()){
- if(EnumerationValue.equals(aLiteral.getName())){
- aEnumerationLiteral=aLiteral;
- }
+ if(att instanceof AttributeValueBoolean){
+ String attributeName=((AttributeValueBoolean)att).getDefinition().getLongName().trim();
+ attributeName = getNormalName(attributeName);
+ Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
+ if( stereotype!=null){
+ Property aProperty=getProperty(stereotype, attributeName);
+ if(aProperty!=null){
+ umlElement.setValue(
+ reqStereotypesMap.get(specType.getLongName()),
+ attributeName,
+ ((AttributeValueBoolean)att).isTheValue());
}
- if( aEnumerationLiteral!=null){
+ }
+ }
+ if(att instanceof AttributeValueInteger){
+ String attributeName=((AttributeValueInteger)att).getDefinition().getLongName().trim();
+ attributeName = getNormalName(attributeName);
+ Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
+ if( stereotype!=null){
+ Property aProperty=getProperty(stereotype, attributeName);
+ if(aProperty!=null){
umlElement.setValue(
reqStereotypesMap.get(specType.getLongName()),
attributeName,
- aEnumerationLiteral);
+ ((AttributeValueInteger)att).getTheValue().intValue());
}
}
}
- }
- }
-
- if(att instanceof AttributeValueXHTML){
- String attributeName=((AttributeValueXHTML)att).getDefinition().getLongName().trim();
- attributeName = getNormalName(attributeName);
- Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
- if( stereotype!=null){
- Property aProperty=getProperty(stereotype, attributeName);
- if(aProperty!=null){
- if((((AttributeValueXHTML)att).getTheValue())!=null){
- if((((AttributeValueXHTML)att).getTheValue().getXhtmlSource())!=null){
+ if(att instanceof AttributeValueReal){
+ String attributeName=((AttributeValueReal)att).getDefinition().getLongName().trim();
+ attributeName = getNormalName(attributeName);
+ Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
+ if( stereotype!=null){
+ Property aProperty=getProperty(stereotype, attributeName);
+ if(aProperty!=null){
umlElement.setValue(
reqStereotypesMap.get(specType.getLongName()),
attributeName,
- ((AttributeValueXHTML)att).getTheValue().getXhtmlSource());
+ ((AttributeValueReal)att).getTheValue());
}
- else{
- try {
- umlElement.setValue(
- reqStereotypesMap.get(specType.getLongName()),
- attributeName,
- //ProrXhtmlSimplifiedHelper.generateXMLString((((AttributeValueXHTML)att).getTheValue())));
- getXmlOnlyString(((AttributeValueXHTML)att).getTheValue()));
- } catch (IOException e) {
- e.printStackTrace();
+ }
+ }
+ if(att instanceof AttributeValueEnumeration){
+ String attributeName=((AttributeValueEnumeration)att).getDefinition().getLongName().trim();
+ attributeName = getNormalName(attributeName);
+ Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
+ if( stereotype!=null){
+ Property aProperty=getProperty(stereotype, attributeName);
+ if(aProperty!=null){
+ if(((AttributeValueEnumeration)att).getValues().size()>0){
+ String EnumerationValue=getNormalName(((AttributeValueEnumeration)att).getValues().get(0).getLongName());
+ //look for Enumeration literal
+ Enumeration aEnumeration= null;
+ //look for attribute
+ Stereotype referedStereotype= reqStereotypesMap.get(specType.getLongName());
+ Property referedAttribute=null;
+ for(Property property:referedStereotype.getAllAttributes()){
+ if(property.getName().equals(attributeName)){
+ referedAttribute=property;
+ }
+ }
+ aEnumeration= (Enumeration)referedAttribute.getType();
+ EnumerationLiteral aEnumerationLiteral=null;
+ for(EnumerationLiteral aLiteral:aEnumeration.getOwnedLiterals()){
+ if(EnumerationValue.equals(aLiteral.getName())){
+ aEnumerationLiteral=aLiteral;
+ }
+ }
+ if( aEnumerationLiteral!=null){
+ umlElement.setValue(
+ reqStereotypesMap.get(specType.getLongName()),
+ attributeName,
+ aEnumerationLiteral);
+ }
+ }
+ }
+ }
+ }
+
+ if(att instanceof AttributeValueXHTML){
+ String attributeName=((AttributeValueXHTML)att).getDefinition().getLongName().trim();
+ attributeName = getNormalName(attributeName);
+ Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
+ if( stereotype!=null){
+ Property aProperty=getProperty(stereotype, attributeName);
+ if(aProperty!=null){
+ if((((AttributeValueXHTML)att).getTheValue())!=null){
+ if((((AttributeValueXHTML)att).getTheValue().getXhtmlSource())!=null){
+ umlElement.setValue(
+ reqStereotypesMap.get(specType.getLongName()),
+ attributeName,
+ ((AttributeValueXHTML)att).getTheValue().getXhtmlSource());
+ }
+ else{
+ try {
+ umlElement.setValue(
+ reqStereotypesMap.get(specType.getLongName()),
+ attributeName,
+ //ProrXhtmlSimplifiedHelper.generateXMLString((((AttributeValueXHTML)att).getTheValue())));
+ getXmlOnlyString(((AttributeValueXHTML)att).getTheValue()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
}
}
}
}
+ else{
+ //set Null value
+ String attributeName=(attDefinition).getLongName().trim();
+ attributeName = getNormalName(attributeName);
+ Stereotype stereotype=reqStereotypesMap.get(specType.getLongName());
+ if( stereotype!=null){
+ Property aProperty=getProperty(stereotype, attributeName);
+ if(aProperty!=null){
+ umlElement.setValue(
+ reqStereotypesMap.get(specType.getLongName()),
+ attributeName,
+ null);
+ }
+ }
+ }
}
}
}
@@ -884,7 +928,10 @@ public abstract class ReqIFImporter extends ReqIFBaseTransformation {
String name=getNormalName(((AttributeDefinitionEnumeration)attributeDef).getType().getLongName());
attribute= stereotype.createOwnedAttribute(attributeName, profileEnumeration.get(name));
}
-
+ //each attribute of the generated stereotype is 0..1
+ if(attribute!=null){
+ attribute.setLower(0);
+ }
if(attributeDef.getDesc()!=null&& attribute!=null){
Comment comment=attribute.createOwnedComment();
comment.setBody(attributeDef.getDesc());
@@ -927,9 +974,8 @@ public abstract class ReqIFImporter extends ReqIFBaseTransformation {
}
if(reqStereotypes.get(reqIFObject.getType().getLongName())!=null){
Class reqClass=null;
- reqClass = createRequirementClass(owner);
+ reqClass = createClassWithRequirementName(owner);
reqClass.applyStereotype(reqStereotypes.get(reqIFObject.getType().getLongName()));
- reqClass.unapplyStereotype(reqClass.getApplicableStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE));
//setID
reqClass.setValue( reqStereotypes.get(reqIFObject.getType().getLongName()),
I_SysMLStereotype.REQUIREMENT_ID_ATT,
@@ -952,11 +998,11 @@ public abstract class ReqIFImporter extends ReqIFBaseTransformation {
/**
- * create a requirement
+ * create a class with requirement name
* @param owner the container of the requirement
- * @return a requirement a class with the stereotype SySML requirement
+ * @return a class that begin with Requirement
*/
- protected abstract Class createRequirementClass(Element owner);
+ protected abstract Class createClassWithRequirementName(Element owner);
diff --git a/tests/recipes/extraplugins/uml/org.eclipse.papyrus.req.reqif.test b/tests/recipes/extraplugins/uml/org.eclipse.papyrus.req.reqif.test
-Subproject 1f33bb4267f120bcea606c7bb654b16391a91bc
+Subproject 08c467ba7408211a7cf5b6cc64826348b2bd3ec

Back to the top