It's all about the answers!

Ask a question

List of Artifacts


Luis Ennser (1675) | asked Apr 29 '10, 1:36 p.m.
Hi,
how do I get a list of artifacts names from a given asset using RAM Client API?

Any sample code?

Thx

3 answers



permanent link
Rich Kulp (3.6k38) | answered May 18 '10, 2:53 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
Featured content is still considered part of the asset. It is so that if
someone pulls down the entire asset they will be able to see the
featured content also.

permanent link
Luis Ennser (1675) | answered May 18 '10, 2:00 p.m.
The code worked fine, but now I am getting an extra artifact, a JPEG of the Fetured Content.
Is this correct? Since this asset was added by RAM and not by the user?

permanent link
Kevin Bauer (34621) | answered Apr 29 '10, 2:24 p.m.
JAZZ DEVELOPER
Hi,
how do I get a list of artifacts names from a given asset using RAM Client API?

Any sample code?

Thx


Here are two ways....

1) Convert the artifacts to a flat list and iterate over that....


RAMFolderArtifact root = (RAMFolderArtifact)asset.getArtifactsRoot();
Artifact[] artifacts = root.computeArtifactsAsFlatList(new RAMStatusMonitor());
for(Artifact artifact : artifacts){
String name = artifact.getName();
//Do something with the name
}


2) Recurse over the artifact tree...


FolderArtifact root = asset.getArtifactsRoot();
List<String> names = new ArrayList<String>();
collectArtifactNames(root, names);

private void collectArtifactNames(FolderArtifact folder, List<String> names){
for(Artifact artifact : folder.getChildren()){
if(artifact instanceof FolderArtifact){
collectArtifactNames((FolderArtifact)artifact, names);
}
else{
names.add(artifact.getName());
}
}
}

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.