Reply To: How to read model from Eclipse builder?

homepage Forums BridgePoint/xtUML Usage and Training How to read model from Eclipse builder? Reply To: How to read model from Eclipse builder?

#1373
sfinnie
Participant

Hi Travis, thanks for the response. I can now get to the Packages for the system; however trying to print the name of each results in an empty string (they are named in the model). I’m obviously missing something – but not sure what?

Builder code now as follows:

[code title=””] protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
throws CoreException {
MessageConsoleStream out = getConsole();

out.println(“Builder called for project ” + getProject().getName());
SystemModel_c sysmdl = getSystemModel(getProject());
if (sysmdl == null) {
out.println(“System model is null”);
} else {
out.println(“System model name: ‘” + sysmdl.Get_name() + “‘”);
for (Package_c pkg: getModelPackages(sysmdl)) {
out.println(“\tPackage name: ‘” + pkg.Get_name() + “‘”);
}
}

out.println(“Builder completed for project ” + getProject().getName());
return null;
}

SystemModel_c getSystemModel(IProject project) {
final String projectName = project.getName();
getConsole().println(“Is Ooa _full_ model loaded? ” + Ooaofooa.getDefaultInstance().isFullModelLoaded());
SystemModel_c sysmdl = SystemModel_c.SystemModelInstance(Ooaofooa.getDefaultInstance(), new ClassQueryInterface_c() {
@Override
public boolean evaluate(Object candidate) {
return ((SystemModel_c) candidate).getName().equals(projectName);
}
});
if (sysmdl == null) {
getConsole().println(“System Model is null”);
}
return sysmdl;
}

Package_c[] getModelPackages(SystemModel_c sysmdl) {
Package_c[] pkgs = Package_c.getManyEP_PKGsOnR1401(sysmdl);
if (pkgs == null) {
getConsole().println(“Package list is null”);
} else {
getConsole().println(“System contains ” + pkgs.length + ” packages”);
}
return pkgs;
}
[/code]

which produces the following output:

[code]
Builder called for project GO
Is Ooa _full_ model loaded? true
System model name: ”
System contains 4 packages
Package name: ”
Package name: ”
Package name: ”
Package name: ”
Builder completed for project GO
[/code]

Is it anything to do with the ‘model loaded’ flags? I notice that isModelLoaded() returns ‘false’even when isFullModelLoaded() returns true. If so is there any way to force model load from the builder?

Thanks,
Scott.