We are using Rational Software Architect to model and generate java artifacts. As of now, we are running the transformation one by one manually.
Our requirement now here is to automate the transformation. I mean want to run the multiple transformation together and log the error if its any.
I have tried to run a transformation from below code. But when I run it, it shows me an error:
I'm trying to load service.tc which is not present in current workspace.
IPath path = new Path("**D://RSA_NewWorkSpace//UML_MODEL_POC/service.tc**");
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
System.out.println("file >> "+file);
ITransformConfig config = TransformConfigUtil.loadConfiguration(file);
System.out.println("inside testExecute 3 config >> "+config);
IStatus status = TransformController.getInstance().execute(config, null, false, null);
System.out.println("status >> "+status);
Error :
file >> L/RSA_NewWorkSpace/UML_MODEL_POC/service.tc
IOException >>java.io.FileNotFoundException: The transformation configuration file /RSA_NewWorkSpace/UML_MODEL_POC/service.tc does not exist. Verify the correct file path was specified.
Is it possible to refer the transformation file from other workspace (instead of current workspace) and load and execute?
I m trying to load the transformation file from D://RSA_NewWorkSpace//UML_MODEL_POC/service.tc.
Below is the latest code which i have been trying to load the transformation file (service.tc) from outside workspace as well as SOP
for.e.g Workspace directory structure
D:\RSA_NewWorkSpace\UML_MODEL_POC\ . project
D:\RSA_NewWorkSpace\UML_MODEL_POC\service.tc
I'm getting config is null . Could you please help me how to get value for config.
public static void obtainLink() {
try {
String projectName = "UML_MODEL_POC";
IProject project = getIProject(getWorkspaceFullPath() + IPath.SEPARATOR + projectName,projectName);
IFile linkFile = project.getFile("service.tc");
if(linkFile.exists())
linkFile.refreshLocal(1, null);
else {
createLink(project, linkFile);
}
**ITransformConfig config = TransformConfigUtil.loadConfiguration(linkFile);**
IStatus status = TransformController.getInstance().execute(config, null, false, null);
System.out.println("status >> "+status);
}
catch(Exception e) {
throw new WrappedException(e);
}
}
public static IProject getIProject(String projectFullPath, String projectName) {
IProjectDescription description;
try {
File projectFile = new File(projectFullPath + IPath.SEPARATOR + ".project");
if (projectFile.exists()) {
description = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(getWorkspaceFullPath() + IPath.SEPARATOR + projectName + IPath.SEPARATOR + ".project"));
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
return project;
}
} catch (CoreException e) {
MessageDialog.openError(null, "Project already exists", "Issue when trying to add project \"" + projectName + "\" to workspace.");
e.printStackTrace();
}
return null;
}
public static String getWorkspaceFullPath() {
return ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
}
SOP:
project = P/UML_MODEL_POC
linkFile = L/UML_MODEL_POC/service.tc
config = null
status = Status CANCEL: unknown code=1 null