Getting the list of projects
This sample demonstrates how to obtain a list of remote projects that exist in the workspace. It also demonstrates how to traverse the children added to the remote projects.
Sample scenario
To retrieve information about z/OS® projects, select the API Samples > Projects Information action.
For each project that is defined, some basic information about the projects and a hierarchical list of data sets and members are displayed. For each child under the project, the applicable COBOL compiler options set for each of them are shown. The output is sent to the standard output associated with the workbench. This information can be found in the Console view of the workbench.

Iterating through all known subprojects
The process of getting the list of projects is similar to getting the list of systems.
The following code snippet iterates through the list of projects and subprojects that are defined in the current workspace.
Object [] projectReferences =
LogicalProjectRegistryFactory.getSingleton().getProjects();
for (int i = 0; i < projectReferences.length; i++) {
ILogicalProject project =
(ILogicalProject) projectReferences[i];
System.out.println("----- Project[" + i + "]: " +
project.getName());
List subProjects = project.getChildren();
for (int j = 0; j < subProjects.size(); j++) {
ILogicalSubProject subProject =
(ILogicalSubProject)subProjects.get(j);
System.out.println(INITIAL_INDENT + "Subproject[" + j +
"]: " + subProject.getName());
printSubproject(subProject, INITIAL_INDENT +
INDENT_PREFIX);
}
}The code starts by using the LogicalProjectRegistry class,
obtained by the getSingleton method of the LogicalProjectRegistryFactory class,
to obtain the list of all ILogicalProject instances
that are defined in the workbench. It then iterates through the list
of known projects, obtaining the children of each project from the getChildren method.
An ILogicalProject object can contain only ILogicalSubProject objects
as children. The ILogicalSubProject objects are in
turn iterated through and processed.
The getName method
obtains the name of the project and the subproject.
Determining whether the associated system is connected
You can determine whether the system
associated with an MVS™ subproject
is connected. After you have a reference to an ILogicalSubProject,
retrieve the IOSImage object that represents the
particular system by using the method getSystems.
Each MVS subproject corresponds
to only one MVS file system.
After you have the IOSImage object, you can determine
whether the system is connected by using the (isConnected) method.
The following code snippet is from the printSubproject sample
method.
if (subProject.getSystems()[0].isConnected()) {
printMembers(subProject, indent);
} else {
......
}Retrieving project or resource properties
The mechanism for retrieving and setting projects might be deprecated and changed.
The getPersistentProperty method
can be used to retrieve project properties. The following code snippet
from the printSubproject sample method retrieves
the COBOL compiler options for the subproject.
String compileOptions = subProject.getPersistentProperty(
IPhysicalResourceCoreConstants.COBOL_COMPILE_OPTIONS);Similarly,
the printMember sample method uses it to retrieve
the COPYLIB associated with the specified resource.
String copyLibraries = resource.getPersistentProperty(IPhysicalResourceCoreConstants.COBOL_COMPILE_COPYLIBRARIES);Traversing the subproject tree structure
To obtain the artifacts added to a subproject,
or any ILogicalContainer objects, use the members method.
The following code snippet is taken from the printMembers method.
An ILogicalSubProject class inherits from the ILogicalContainer class.
IAdaptable [] members = container.members();
for (int j = 0; j < members.length; j++) {
printMember((ILogicalResource) members[j], indent + INDENT_PREFIX);
}The printMember method then
prints the appropriate information for the current resource. If the
current resource is an ILogicalContainer, it co-recursively
starts the printMembers method to descend into the
subtree.
if (resource instanceof ILogicalContainer) {
ILogicalContainer memberContainer = (ILogicalContainer) resource;
......
printMembers(memberContainer, indent);
} else {
System.out.println(indent + "member[" + index + "] " + resource.getName()
+ " having COBOL copy libraries: " + copyLibraries);
}