cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Locate members existing in a subproject and all its child subprojects

amatei
13-Aquamarine

Locate members existing in a subproject and all its child subprojects

Hello,

We are using Integrity Client version 10.8.0.8356

My project has a hierarchical structure of subprojects containing file members and other subprojects

+project.pj

  +Documentation\project.pj

  - Release\project.pj

     - src\project.pj

         - core\project.pj

               member1.java

               member2.doc

         - tests\project.pj

                TestCase1.java

                TestCase2.java

I would  like to be able to search (locate) file members existing in the src subproject and all its child subprojects (i.e. core and tests)

Unfortunately the si locate command does not seem to allow searching by starting from a selected subproject (i.e. src) in a recursive manner

I use the si locate command according to the SourceCLIReference_Integrity_10_6.pdf documentation

a) If I use --projectscope=this option , then only the immediate children members of the src subproject are found, no downwards recursive search appears to be performed in contained subprojects

si locate --hostname=someServer --port=somePort --user=someUser --project=t:/..../src/project.pj  --depth=current   --noexactmatch  --nocasesensitive  --projectscope=this --memberbyname=member1

b) If I use the  --projectscope=all option, then all the registered projects on the server are searched, which is not what I want, sorry. There are far too many projects on the server to search in all of them.

si locate --hostname=someServer --port=somePort --user=someUser --project=t:/..../src/project.pj  --depth=current   --noexactmatch  --nocasesensitive  --projectscope=all --memberbyname=member1

Any help is welcome, thank you!

ACCEPTED SOLUTION

Accepted Solutions
llambert
12-Amethyst
(To:amatei)

Hi Alexandru,

I cannot help you with core functionality but i have a custom written search tool that can be plugged into the client as a custom action and it will work through subprojects.  Let me know if you want this tool.  Again, it was built by PTC field team so is not maintained by PTC support but still works across many versions of ILM.

View solution in original post

9 REPLIES 9
llambert
12-Amethyst
(To:amatei)

Hi Alexandru,

I cannot help you with core functionality but i have a custom written search tool that can be plugged into the client as a custom action and it will work through subprojects.  Let me know if you want this tool.  Again, it was built by PTC field team so is not maintained by PTC support but still works across many versions of ILM.

amatei
13-Aquamarine
(To:llambert)

Hello Lance,

Yes, certainly it would be very helpful to see how it works, thank you.

How can I have access to the tool ?

kthierer
12-Amethyst
(To:amatei)

I dont know if that helps but

The only method I found generating some kind of parseable project tree (with 10.4) was something like

si viewproject -R -P D:/project/on/server/project.pj --projectRevision=1.3 --filter=file:NO_MATCH

I would also be interrested in a command/method to output the project and all the subprojects within

the tree as a list of absolute server paths.

Anyhow form the performance aspect it might be better for you to filter/parse the results

of 'si locate --projectscope=all'.

HTH Jürgen

amatei
13-Aquamarine
(To:kthierer)

Hello Klaus,

Because you mentioned about the si viewproject command, I I don't know what NO_MATCH means ? Can you explain please ?

When I want to enumerate the content of a project and also filter by member name, then I use this syntax:

si viewproject  --hostname=someServer --port=somePort --user=someUser --project=t:/..../src/project.pj  --R --filter=file:*.java

In the example above I wanted to find all java files in a project, that is where the file extension is .java.

>Anyhow form the performance aspect it might be better for you to filter/parse the results

>of 'si locate --projectscope=all'.

Yes, you are right, in the end this is the solution.

>I would also be interrested in a command/method to output the project and all the subprojects within

the tree as a list of absolute server paths.

This is certainly possible if you will use mksapi.jar and execute the si viewproject  command in Java.

Example below:

Java Code Example com.mks.api.Command

kthierer
12-Amethyst
(To:amatei)

Hello Alexandru

That "NO_MATCH" was just a dirty trick to make viewproject outputting only subproject and not members.

It should then rather be something like "A_MEMBER_NAME_THAT_WILL_NEVER_EXIST"

or a filter without dirty trick (do you know one? )

Thanks for that link.

I'm not that fit in java but I suppose you would recommend me using Project.java and add a function "listSubProjects"

using "listFiles" as template.

Project.java
/**
* Parses the output from the si viewproject command to get a list of members
* @param workspaceDir The current workspace directory, which is required for an export
* @return The list of Member objects for this project
* @throws APIException
*/
public List<Member> listFiles(String workspaceDir) throws APIException {
  List<Member> memberList=new ArrayList<Member>();
  Hashtable<String,String> pjConfigHash=new Hashtable<String,String>();
  pjConfigHash.put(projectName,fullConfigSyntax);
  String projectRoot=projectName.substring(0,projectName.lastIndexOf('/'));
  Command siViewProjectCmd=new Command(Command.SI,"viewproject");
  siViewProjectCmd.addOption(new Option("recurse"));
  siViewProjectCmd.addOption(new Option("project",fullConfigSyntax));
  MultiValue mvFields=new MultiValue(",");
  mvFields.add("name");
  mvFields.add("context");
  mvFields.add("memberrev");
  mvFields.add("membertimestamp");
  mvFields.add("memberdescription");
  siViewProjectCmd.addOption(new Option("fields",mvFields));
  api.getLogger().info("Preparing to execute si viewproject for " + fullConfigSyntax);
  Response viewRes=api.runCommand(siViewProjectCmd);
  WorkItemIterator wit=viewRes.getWorkItems();
  while (wit.hasNext()) {
    WorkItem wi=wit.next();
    if (wi.getModelType().equals(SIModelTypeName.SI_SUBPROJECT)) {
      pjConfigHash.put(wi.getField("name").getValueAsString(),wi.getId());
    }
    else     if (wi.getModelType().equals(SIModelTypeName.MEMBER)) {
      String parentProject=wi.getField("parent").getValueAsString();
      Member iCMMember=new Member(wi,pjConfigHash.get(parentProject),projectRoot,workspaceDir);
      memberList.add(iCMMember);
    }
    else {
      api.getLogger().warn("View project output contains an invalid model type: " + wi.getModelType());
    }
  }
  Collections.sort(memberList,FILES_ORDER);
  return memberList;
}

BTW:

If its just for the purpose of listing files with pathinfo I often use

  si rlog --noheaderformat --notrailerformat -R --revision=:member --fields=membername,memberrev,archivename [-P %SERVER_PJ% --projectrevision=%PJ_REV%]

I would be curious if there is a significant difference in performance here compared to viewproject.

Regards Jürgen

amatei
13-Aquamarine
(To:kthierer)

Hi  Klaus,

I mean someone with a Java compiler (NetBeans 8.2 for example) can build a customized tool to execute the si viewproject command on a project

- the Java API documentation from IntegrationsBuilderGuide_Integrity_10_8.pdf and the web site I mentioned are quite useful

- the Java API is contained within mksapi.jar, which is installed in "C:\Program Files (x86)\Integrity\IntegrityClient10.6\lib\mksapi.jar"

After execution, the result is a list of WorkItem structures that seem to display absolute server paths, like you wanted

For example if the project t:/.../Hardware/project.pj  has

two subprojects: Description and Quality

one file member: MyTest.txt

the result would look like this

workItem: #t:/...#Hardware#s=Description/Theme/project.pj (3)
name:t:/.../Hardware/Description/Theme/project.pj (java.lang.String)
parent:t:/.../Hardware/project.pj (java.lang.String)
type:subproject (java.lang.String)

workItem: #t:/...#Hardware/Quality (3)
name:t:/.../Hardware/Quality/project.pj (java.lang.String)
parent:t:/.../Hardware/project.pj (java.lang.String)
type:subproject (java.lang.String)


workItem: MyTest.txt (7)
name:t:/.../Hardware/MyTest.txt (java.lang.String)
parent:t:/.../Hardware/project.pj (java.lang.String)
type:archived (java.lang.String)
memberrev:1.3.1.4.1.1 (com.mks.api.response.Item)
memberrevlockedbyme:null (null)
workingrevlockedbyme:null (null)
lockrecord: (com.mks.api.response.ItemList)

ilampe
5-Regular Member
(To:llambert)

Hello,

 

I have  a similar problem.

I planned to write some sripts, but I canceled this.

 

It is possible  to get this tool too.

 

It is only for getting and not for  productive use.

 

I would appreciate  if you can give me that tool.

 

Thanks and I hope to hear from you.

 

Ingo

 

 

 

Hello all,

 

Even we have a similar requirement of viewing the project structure tree at one shot. Kindly help me with the tool. Thank you so much for your help!!!

 

Regards,

Sailesh Mohan

bauerm
2-Explorer
(To:llambert)

Hello,

can I get access to this tool.

Regards

M.Bauer

Announcements


Top Tags