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.
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 that have been added 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 can be found in the DOS window from which the workbench was started, or in the Console view of the hosting workbench in the case of the runtime workbench.

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 defined in the workbench. It then iterates through the list of known projects, obtaining the children of each project using the getChildren method. An ILogicalProject object can contain only ILogicalSubProject objects as children. The ILogicalSubProject objects are in turn iterated through and processed.
The methods getName method allows you to obtain the name of the project and the subproject respectively.
It is easy to determine if the system associated with an MVS™ subproject is connected. Once you have a reference to an ILogicalSubProject, retrieve the IOSImage object representing the particular system using the method getSystems. Each MVS subprojects correspond to one and only one MVS file system. Once you have the IOSImage object, you can determine if the system is connected by invoking the (isConnected) method. The following code snippet is from the printSubproject sample method.
if (subProject.getSystems()[0].isConnected()) {
printMembers(subProject, indent);
} else {
......
}
The mechanism for retrieving and setting projects may be deprecated and changed in future.
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 given subproject.
String compileOptions = subProject.getPersistentProperty( IPhysicalResourceCoreConstants.COBOL_COMPILE_OPTIONS);
Similarly, the printMember sample method uses it to retrieved the COPYLIB associated with the specified resource.
String copyLibraries = resource.getPersistentProperty(IPhysicalResourceCoreConstants.COBOL_COMPILE_COPYLIBRARIES);
To obtain the artifacts added to a given 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 would then print out the appropriate information pertaining the current resource. If the current resource is an ILogicalContainer, it would co-recursively invoke 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);
}