It's all about the answers!

Ask a question

how to get streams by project area using OSLC API/programatically


akshay p (15116) | asked Aug 27 '19, 2:36 a.m.
edited Sep 12 '19, 1:12 a.m. by Ralph Schoon (63.1k33645)

how to get streams by project area using OSLC API/programatically

3 answers



permanent link
Param S (279) | answered Sep 11 '19, 1:10 p.m.
Have you tried with the below Plain Client Java API approach:

. get a handle to project area

. get all team areas from project area projectarea.getTeams
. iteration over each team area handle and call IWorkspaceManager.findAllWorkspaceNames

Now to get detailed information on any of the above obtained names
. create a IWorkspaceSearchCriteria instance
. set its kind as IWorkspaceSearchCriteria.STREAMS
. set its exact name as the above searched name
. call IWorkspaceManager.findWorkspaces to get the details


permanent link
Luca Martinucci (1.0k294112) | answered Sep 12 '19, 3:01 a.m.
edited Sep 12 '19, 3:02 a.m.
This is how I get all streams in a given project area using plain Java API:

IProjectArea projectArea = ...;
String repositoryURI = "https://myserver.jazz.com:9443/jts";
ITeamRepository teamRepository = TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
IWorkspaceManager workspaceManager = (IWorkspaceManager) teamRepository.getClientLibrary(IWorkspaceManager.class);
List<IWorkspace> streams = new ArrayList<IWorkspace>();

IWorkspaceSearchCriteria workspaceSearchCriteria = IWorkspaceSearchCriteria.FACTORY.newInstance();
workspaceSearchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS);
try {
List<IWorkspaceHandle> workspaceHandles = workspaceManager.findWorkspaces(workspaceSearchCriteria, Integer.MAX_VALUE, null);
for (IWorkspaceHandle workspaceHandle : workspaceHandles) {
IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandle, null);
IProcessAreaHandle wsProcessAreaHandle = workspaceConnection.getProcessArea(null);
if (wsProcessAreaHandle != null) {
String wsProcessAreaHandleUUID = wsProcessAreaHandle.getItemId().getUuidValue();
if (wsProcessAreaHandleUUID.equals(projectArea.getItemId().getUuidValue())) {
IWorkspace stream = (IWorkspace) teamRepository.itemManager().fetchCompleteItem(workspaceHandle, IItemManager.DEFAULT, null);
streams.add(stream);
}
}
}
} catch (TeamRepositoryException e) {
e.printStackTrace();
}
 

permanent link
Matthias Buettgen (23612131) | answered Sep 12 '19, 12:58 p.m.
edited Sep 12 '19, 1:02 p.m.
If you're interested in using OSLC/API programmatically I propose the Lyo framework (https://www.eclipse.org/lyo/).
Here you'll find everything required to connect to CLM and un-marshall the RDF/XML into Java Objects. The latest stable release is 2.4.0.
It needs to be mentioned that Lyo doesn't support configurations for the time being, but you can create your own Configuration class and unmarshall the CLM configuration into a Configuration object. Find below a sample how this Configuration class can look like.


public static final String CONFIGUTATION_MANAGEMENT_DOMAIN    = "http://open-services.net/ns/config#"; public static final String CONFIGUTATION_MANAGEMENT_PREFIX  = "oslc_config";
public static final String CONFIGURATION  = CONFIGUTATION_MANAGEMENT_DOMAIN + "Configuration";
public static final String JAZZ_PROCESS_MANAGMENT_DOMAIN   = "http://jazz.net/ns/process#";
@OslcNamespace(CONFIGUTATION_MANAGEMENT_DOMAIN)
@OslcResourceShape(title = "Stream Resource Shape", describes = CONFIGURATION)

public class Configuration extends AbstractResource {
    
    private String     title;
    private URI          serviceProvider;
    private URI          projectArea;
    private URI     baselines;
    private URI        component;
    
    private final Set<URI>      rdfTypes                    = new TreeSet<URI>();

    public Configuration() {
        
        super();
        
    }
    
    public Configuration(final URI about) {
        
        super(about);
        
    }
    
    public void addRdfType(final URI rdfType)
    {
        this.rdfTypes.add(rdfType);
    }
    
    @OslcDescription("Title (reference: Dublin Core) or often a single line summary of the resource represented as rich text in XHTML content.")
    @OslcOccurs(Occurs.ExactlyOne)
    @OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "title")
    @OslcTitle("Title")
    @OslcValueType(ValueType.XMLLiteral)
    public String getTitle()
    {
        return title;
    }
    
    @OslcDescription("The scope of a resource is a URI for the resource's OSLC Service Provider.")
    @OslcPropertyDefinition(OslcConstants.OSLC_CORE_NAMESPACE + "serviceProvider")
    @OslcRange(OslcConstants.TYPE_SERVICE_PROVIDER)
    @OslcTitle("Service Provider")
    public URI getServiceProvider()
    {
        return serviceProvider;
    }
    
    @OslcDescription("The scope of a resource is a URI for the resource's baselines.")
    @OslcPropertyDefinition(CONFIGUTATION_MANAGEMENT_DOMAIN + "baselines")
    @OslcTitle("Baselines")
    public URI getBaselines()
    {
        return this.baselines;
    }
    
    @OslcDescription("The scope of a resource is a URI for the resource's baselines.")
    @OslcPropertyDefinition(CONFIGUTATION_MANAGEMENT_DOMAIN + "component")
    @OslcTitle("Component")
    public URI getComponent()
    {
        return this.component;
    }
    
    @OslcDescription("The scope of a resource is a URI for the resource's project area.")
    @OslcPropertyDefinition(JAZZ_PROCESS_MANAGMENT_DOMAIN + "projectArea")
    @OslcTitle("Project Area")
    public URI getProjectArea()
    {
        return this.projectArea;
    }
    
    @OslcDescription("The resource type URIs.")
    @OslcName("type")
    @OslcPropertyDefinition(OslcConstants.RDF_NAMESPACE + "type")
    @OslcTitle("Types")
    public URI[] getRdfTypes()
    {
        return rdfTypes.toArray(new URI[rdfTypes.size()]);
    }
    
    public void setTitle(final String title)
    {
        this.title = title;
    }
    
    public void setServiceProvider(final URI serviceProvider)
    {
        this.serviceProvider = serviceProvider;
    }
    
    public void setBaselines(final URI baselines)
    {
        this.baselines = baselines;
    }
    
    public void setComponent(final URI component)
    {
        this.component = component;
    }
    
    public void setProjectArea(final URI projectArea)
    {
        this.projectArea = projectArea;
    }
    
    public void setRdfTypes(final URI[] rdfTypes)
    {
        this.rdfTypes.clear();
        if (rdfTypes != null)
        {
            this.rdfTypes.addAll(Arrays.asList(rdfTypes));
        }
    }
}

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.