net.sf.nakeduml.emf.extraction.EmfExtractionPhase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of metamodel Show documentation
Show all versions of metamodel Show documentation
A uml code generator and execution engine
The newest version!
package net.sf.nakeduml.emf.extraction;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import net.sf.nakeduml.detachment.DetachmentPhase;
import net.sf.nakeduml.emf.workspace.EmfWorkspace;
import net.sf.nakeduml.feature.InputModel;
import net.sf.nakeduml.feature.NakedUmlConfig;
import net.sf.nakeduml.feature.PhaseDependency;
import net.sf.nakeduml.feature.TransformationPhase;
import net.sf.nakeduml.linkage.LinkagePhase;
import net.sf.nakeduml.metamodel.core.INakedPackage;
import net.sf.nakeduml.metamodel.workspace.INakedModelWorkspace;
import net.sf.nakeduml.metamodel.workspace.MappedType;
import net.sf.nakeduml.metamodel.workspace.internal.NakedModelWorkspaceImpl;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Package;
@PhaseDependency(after = DetachmentPhase.class, before = {LinkagePhase.class })
public class EmfExtractionPhase implements TransformationPhase {
public static final String MAPPINGS_EXTENSION = "mappings";
@InputModel(implementationClass = NakedModelWorkspaceImpl.class)
private INakedModelWorkspace modelWorkspace;
@InputModel
private EmfWorkspace emfWorkspace;
private NakedUmlConfig config;
public void initialize(NakedUmlConfig config) {
this.config = config;
}
public Object[] execute(List features) {
modelWorkspace.setWorkspaceMappingInfo(emfWorkspace.getMappingInfo());
for (Package gp : emfWorkspace.getGeneratingModelsOrProfiles()) {
modelWorkspace.addGeneratingModelOrProfileId(getIdFor(gp));
}
for (Element e : emfWorkspace.getOwnedElements()) {
URI mappedTypesUri = e.eResource().getURI().trimFileExtension().appendFileExtension(MAPPINGS_EXTENSION);
try {
InputStream inStream = e.eResource().getResourceSet().getURIConverter().createInputStream(mappedTypesUri);
Properties props = new Properties();
props.load(inStream);
Set> entrySet = props.entrySet();
for (Entry