It's all about the answers!

Ask a question

How to list repository files which belongs to a component?


arafath Arafath (1163) | asked Nov 25 '09, 10:04 a.m.
I want to enforce custom validation for the files connected to jazz source control.

My requirement......
I have connected to jazz repository which has 2 project areas.
I have created few streams in each project area. Also i have created few components under each stream. I am able to load the component and able to perform check-in,check-out operations without any problem.
I would like to introduce file validation. whenever an user creates a new file, i would like to validate whether the filename exists across components. Let us assume the following ...

Stream Main has 2 components component1 & component2.

Componet1 has following files....

FileA
FileB

Componet2 has following files....

Filea
Fileb

If a user attempts to create FileA in component2, i should warn the user since the filename "FileA" already exists in Componet1.

My question is...

How can i query the RTC to list repository file details that belongs to a particular component / stream ? Also how i can get the stream objects from ProjectArea? I need help to achieve this requirement?

6 answers



permanent link
Andrew Hoo (1.0k1) | answered Dec 03 '09, 11:38 a.m.
JAZZ DEVELOPER
When you have a stream, you can get the IConfiguration for components, and
then call fetchAncestorsByName. That will get you a list of full paths of
all the items with that name.

You can use something along the liens of this to find streams from a
project area:

IWorkspaceSearchCriteria criteria =
IWorkspaceSearchCriteria.FACTORY.newInstance().setKind(IWorkspaceSearchCriteria.STREAMS);
criteria.getFilterByOwnerOptional().addAll(Collections.singleton(projectArea));
SCMPlatform.getWorkspaceManager(repo).findWorkspaces(criteria, maxResults,
null);

On Wed, 25 Nov 2009 10:08:02 -0500, yasararafath
<arafathcse> wrote:

I want to enforce custom validation for the files connected to jazz
source control.

My requirement......
I have connected to jazz repository which has 2
project areas.
I have created few streams in each project area. Also i have created
few components under each stream. I am able to load the component and
able to perform check-in,check-out operations without any problem.
I would like to introduce file validation.
whenever an user creates a new file, i would like to validate
whether the filename exists across components. Let us assume the
following ...

Stream Main has 2 components component1 & component2.

Componet1 has following files....

FileA
FileB

Componet2 has following files....

Filea
Fileb

If a user attempts to create FileA in component2, i should warn the
user since the filename "FileA" already exists in
Componet1.

My question is...

How can i query the RTC to list repository file details that belongs
to a particular component / stream ? Also how i can get the stream
objects from ProjectArea? I need help to achieve this requirement?



--

permanent link
arafath Arafath (1163) | answered Dec 04 '09, 1:34 a.m.
Hi,
Thank you very much for your response.

Doubt 1:
********
How to get a stream object for a particular Project area ?

I tried the following code....


IWorkspaceSearchCriteria search = IWorkspaceSearchCriteria.FACTORY.newInstance();
search.setKind(IWorkspaceSearchCriteria.STREAMS);
List<IProjectArea> projectAreas = getAllProjectAreas(repository);
// getAllProjectAreas() will return the available project areas in a
// repository
List<IWorkspaceHandle> handles = workspaceManager.findWorkspaces(search, Integer.MAX_VALUE, null);

for(IWorkspaceHandle handle :handles ){

IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(handle, null);
System.out.println(" Streams: " + workspaceConnection.getName());

}


The above code prints all the stream names. But if i include the following line

search.getFilterByOwnerOptional().addAll(Collections.singleton(projectAreas.get(0)));

I am not getting any handles. Whats wrong in the above code? I have passed
IProjectArea object to the singleton().



Doubt 2:
*******
How to get IConfiguration for components?

I tried the following code,


IItemManager itemManager = repository.itemManager();

IComponentSearchCriteria comSearch = IComponentSearchCriteria.FACTORY.newInstance();

List<IComponentHandle> comHandles = workspaceManager.findComponents(comSearch, Integer.MAX_VALUE, null);
List<IComponent> iComponents = itemManager.fetchCompleteItems(comHandles, Integer.MAX_VALUE, null);


IComponentHandle componentHandle = iComponents.get(0);
IWorkspaceHandle wshandle = handles.get(0);
IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(wshandle, null);
IConfiguration configuration = workspaceConnection.configuration(componentHandle);



I dont know which IComponentHandle object needs to pass to the configuration() . Also i dont know which IWorkspaceHandle object needs to be passed to getWorkspaceConnection() to get the IWorkspaceConnection
object. So the current code throws the following exception



com.ibm.team.scm.common.ComponentNotInWorkspaceException: Component is not in workspace
at com.ibm.team.scm.client.internal.FlowNodeConnection.checkKnownComponent(FlowNodeConnection.java:1361)
at com.ibm.team.scm.client.internal.FlowNodeConnection.configuration(FlowNodeConnection.java:935)
at com.smi.tools.eclipse.basic.actions.remote.GetFileFromServerActionDelegate.run(GetFileFromServerActionDelegate.java:218)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500)
at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)

I need help in solving these problems..

permanent link
jaya krishna (11612112) | answered Jan 27 '10, 9:28 a.m.
Hi,

I am new to RTC and I am confused with few options during loading. Could you explain my below queries. It would be great if you can provide me an example also.

When i select Repository workspace and select load option, i am displayed with 5 options. Please explain below options with an example.

1. Find and Load Eclipse Projects.
2. Load the root folder of the components as projects.
3. Browse the components to select the folders to be loaded.
5. Reload the projects that are out of sync. Local changes will be overwritten.

I am confused with option 2 and 3 more. Can you also differentiate thes both. Thanks in Advance.

permanent link
Michael Valenta (3.7k3) | answered Jan 28 '10, 10:08 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Options 2 and 3 are essentially the same. The only difference is that,
if you select option 2, you can click Finish without going to the next
page and the top-level folders will be loaded.

Michael

jayakrishna wrote:
Hi,

I am new to RTC and I am confused with few options during loading.
Could you explain my below queries. It would be great if you can
provide me an example also.

When i select Repository workspace and select load option, i am
displayed with 5 options. Please explain below options with an
example.

1. Find and Load Eclipse Projects.
2. Load the root folder of the components as projects.
3. Browse the components to select the folders to be loaded.
5. Reload the projects that are out of sync. Local changes will be
overwritten.

I am confused with option 2 and 3 more. Can you also differentiate
thes both. Thanks in Advance.

permanent link
jaya krishna (11612112) | answered Feb 01 '10, 6:44 a.m.
Hi Michael,

Thanks for your reply. It would be great if you can answer my below queries:
1) When does option 5 come into picture, can you provide us with a samll example.
2) As per my knowledge the difference between option 1 and option 2 is, in option 1 we will not be displayed with sub folders under a eclipse project where as in option 2 we can select or deselect the subfolders. Please comment.

Thanks in Advance.

Regards,
Jay.

Options 2 and 3 are essentially the same. The only difference is that,
if you select option 2, you can click Finish without going to the next
page and the top-level folders will be loaded.

Michael

jayakrishna wrote:
Hi,

I am new to RTC and I am confused with few options during loading.
Could you explain my below queries. It would be great if you can
provide me an example also.

When i select Repository workspace and select load option, i am
displayed with 5 options. Please explain below options with an
example.

1. Find and Load Eclipse Projects.
2. Load the root folder of the components as projects.
3. Browse the components to select the folders to be loaded.
5. Reload the projects that are out of sync. Local changes will be
overwritten.

I am confused with option 2 and 3 more. Can you also differentiate
thes both. Thanks in Advance.

permanent link
Michael Valenta (3.7k3) | answered Feb 01 '10, 9:23 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Jay

For me, option 2 has both Next and Finish enabled while option 3 only
has Next enabled. If you are seeing otherwise, please take a screenshot
and open a work item as this would be a bug of some sort. As for option
5, that is useful when the local workspace becomes out-of-sync with the
remote workspace. This can happen, for instance, when an error occurs
during an accept or a load operation or in several other ways as well.

Michael.

jayakrishna wrote:
Hi Michael,

Thanks for your reply. I am confused with your answer.
What i observed here is in both the cases i see only Finish button
enabled, irrespective of the option 2 or 3 selection next button is
disabled in both the cases. Please clarfiy.

When does option 5 come increateAndLockForReadingto picture, can you provide us with a samll
example.

Thanks in Advance.

Regards,
Jay.

Michael Valentawrote:
Options 2 and 3 are essentially the same. The only difference is
that,
if you select option 2, you can click Finish without going to the
next
page and the top-level folders will be loaded.

Michael

jayakrishna wrote:
Hi,

I am new to RTC and I am confused with few options during loading.
Could you explain my below queries. It would be great if you can
provide me an example also.

When i select Repository workspace and select load option, i am
displayed with 5 options. Please explain below options with an
example.

1. Find and Load Eclipse Projects.
2. Load the root folder of the components as projects.
3. Browse the components to select the folders to be loaded.
5. Reload the projects that are out of sync. Local changes will be
overwritten.

I am confused with option 2 and 3 more. Can you also differentiate
thes both. Thanks in Advance.

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.