Dxl view move objects - ibm-doors

Can you move an entire object from one view to another (without deleting it in one view, load another view, create object in the new view and populate it ? If yes, can you tell me how or point me in the right direction? And also, how can i get the information from the last column, without needing to iterate though all the columns. Thanks.

Concerning the comment on using the second script in a DXL attribute:
DXL attributes do not work this way.
in a DXL attribute you would never have a loop over all objects, you only refer to a single object and you calculate a value for this object's attribute.
accept and reject work on views, DXL attributes have a content, these are different concepts.
If you want to use DXL attributes, you might have one of type boolean and use a script like
bool showMe=false
// in DXL Attributes, obj contains the currently evaluated object (not the "current" object!)
if intOf(obj."Absolute Number""") == 10 then showMe=true
if intOf(obj."Absolute Number""") > 20 then showMe=true
// the name of the DXL Attribute is stored automatically in the variable attrDXLName
obj.attrDXLName = showMe
and then you have a view with a filter that shows only these objects where the attribute's value is "true"

You need to be a bit more precise in your wording, it is unclear what you want.
In DOORS, a Module contains objects. The structure of the module determines which attributes each object has. Views are a, well, a view on these objects. A view determines which attributes of the object are shown, these are the columns shown in a view. Additionally, a view can have a filter, which determines which objects of the module are shown.
So, to answer your question, if one view of a module contains an object and another view of the same module does not show that object, you need to adopt the filter of the other view.
Your second question is about DXL, right? No, I do not know of a function that tells you the number of columns in a view, so that you can use the column (index) function to get the last column, but a small loop
Column cLast
for cLast in m do {}
// now cLast contains the last column of the current view
should not hurt. But are you sure that you really want to work with columns? Usually, scripts rather deal with attributes of objects, and only rarely with columns (the exception being dxl layout columns and of course scripts that manipulate views).
Update: to add to my comment about filters in views, there actually is a way of adding single objects to a view, i.e. the accept/reject method. You could have a script like
Object o
for o in entire current Module do {
reject o
if intOf(o."Absolute Number""") == 10 then accept o
if intOf(o."Absolute Number""") > 20 then accept o
if o."Requrement type""" == "Functional" then accept o
}
filtering on
but this addition will be very short-lived: as soon as you change the view, it forgets that sort of filtering, even if you save the view. So, again, it is not a move.

Related

IBM DOORS how to import rows from excel to specific place in DOORS

I have some rows in DOORS identified by a number. For example
Object Identifier
Description
1
description of object 1
2
description of object 2
3
description of object 3
4
description of object 4
I know if I want to modify an existing object, I just import an excel that has the columns Object Identifier and Description with the same number in the Object Identifier column, as the object I want to modify.
If I want to create new objects, I import rows with empty Object Identifier column. They get the identifier assigned automatically and will be inserted in the bottom of the table in DOORS.
But I want to modify some existing objects and create a new object specifically under the second object.
Object Identifier
Description
1
modified description of object 1
2
description of object 2
5
new object
3
modified description of object 3
4
description of object 4
How can I do this in one import?
I'm not aware of an official support for this. One method could be to have an additional column called e.g. "below". In this column, the excel editor might enter the object number of the parent object.
Then, after you imported your excel to DOORS, you would run a code like this, which moves every object where "below" is set, below the referenced parent object
Object o
Module m = edit … (or current or whatever)
Skip sk = create
for o in m do {
put sk, o, o
}
for o in sk do {
int iBelow = intOf realOf (o."below""")
if (iBelow) {
move o, below object iBelow
o."below" = ""
}
}
save m
As far as I remember while screwing up a whole DOORS module, when you select to import (the excel file in a csv format), you can choose to update or create.
If you pick update, it will ask for the column with unique identifiers (usually, the object IDs column) and for the objects that doesn't have a number, they will be created, updating the ones that do have an ID, but (as you state in the question) the new ones will be added at the bottom.
Now, we are only using the ID attribute of the objects, which makes them unique even if is moved, deleted or flushed, but for the meaning of sorting, that attribute is meaningless, because if you copy an object (from the same module or from another) the ID updates to the next available according to the ones in the module.
The attribute that tells DOORS how to structure and sort the objects, is actually the Object Number
"... hierarchical ..." is the keyword here. That attribute tells DOORS the order of the objects and which is parent/children of which.
Now, I don't really remember if that attribute can be modified in the csv, but there are two DXL scripts that combined, enable that while importing:
\IBM\Rational\DOORS\X.Y\lib\dxl\example\oslc\ hierarchy.dxl
\IBM\Rational\DOORS\X.Y\lib\dxl\standard\import\ commas.dxl
Unfortunatelly, I couldn't find the combined script, but I know it uses those 2 (some time ago I was making the DXL to do almost the same as you want, but someone else at my work managed to do it first and with time, it was no longer necessary)
Here is the reference manual (image is from page 402/1006)
And this page has some good scripts, too.
I hope my answer helps you to build that script (or find some coworkers that do it before you do, hehe)

Remove item from filter list as well as from original list

I am working on UISearchBar on Swift 4.0. I have originalList[ModelItem] and filterList[ModelItem]. While in searching lets say user wants to delete on filterList 5th position which is 10th item on actual originalList. It make sense to delete this item from both of the list right? Items have no id or similar type field.
What would be the basic steps for such both-way deletion? I was looking for a general idea of achieving this.
If the model is a class and the filterList is created directly from the originalList (no new objects created, but both lists reference the same objects), then you can use this code:
let itemToDelete = filterList.remove(at: indexPath.row)
if let index = originalList.index(where: { $0 === itemToDelete }) {
originalList.remove(at: index)
}
print(originalList)
print(filterList)
=== operator will test the equality of the instances, thus identifying the proper instance to be removed from originalList.
In case you are using struct as a model, you will have to implement Equatable with some heuristics that would be able to detect if two instances are equal or not even without having an explicit identifier and then use == to find the proper instance in originalList to be removed.
Another alternative might be implementing search with index method, that would use the same filtering algorithm as your current filter method, but would take one more parameter - index in the filterList (filterIndex) along with the filter text, and based on that would compute and return an index in the originalList that matches the provided pair of filter text and filterIndex.
Yet another alternative, which I would not recommend (I would call it a hack) - you can keep a dictionary of indexes from originalList to filterList which you can use to have explicit mapping between originalList and filterList. This would however require that you always update that dictionary whatever change is made to one of the lists - every search, every deletion or removal or insertion would require an update of the mapping dictionary. This seems way to complicated and error prone.
You have a number of options.
You can maintain a mapping between the original and the filtered items positions, so you can perform deletion on both lists.
You can make your items identifiable, so you can search for the corresponding item in the original list and delete it. Note that all reference types can be tested for identity (===).
You can work with a filtered "view" to the original list, and not with a filtered copy, so the deletion will be performed on the original list naturally.
I don't think we have a standard solution for the latter option, which makes this approach the most complicated.
When choosing either of the first two options be careful with the original list updates that can happen while you operate on the filtered copy.

Multiple subreports for each value in a field for a parameter

I have a Report and a Subreport, with the Report having 30 instances of the Subreport organized to fit neatly on the page. The only parameter for the Subreport is Child and the only parameter for the Report is Parent (not the actual values but it might make it easier/more generalized for other people that see this). The data comes from a data source SQL_Source and stored proc dbo.StoredProc saved as Dataset1.
I need each subreport instance to use the next Child as its parameter from Parent. At the moment, each instance of the Subreport in Report takes in the parameter Child, but only the first value (with the name Child and value [Child]. If I set the value to Last(Fields!Child.Value, "Dataset1") then it will use the last value for the Parent as the parameter, so I know it can see them all. I'm simply trying to get it to retrieve all of them, which will be a variable amount depending on the Parent.
Sorry if it's a wall of text, anybody know if this is possible?
In SSRS, there's no function can work like an "opposite" Previous() function. For your requirement, I suggest a workaround is to join the parent and child table. Make each parent along with next child. Maybe you can submit a feature to MS and let them create a next() function or something like that.
I can create a tablix of subreports, it will display the subreport for each Child as the tablix increments.

How to access Set element in JSF 2?

i want to get specific element in a Set in JSF 2
please advise how to do that.
This problem is not specific to JSF/EL. Already in plain Java you cannot access a specific element in a Set. The Set has no method like get(index) as the List has. You need to convert the Set<T> to a T[] array or a List<T> so that you can access it by an index.
This works in a predictable way for SortedSet or LinkedHashSet only as the elements are then inserted in respectively the sorted order or insertion order. This would not make any sense when it's a HashSet as you cannot reliably predict beforehand at which index the element would end up.
If you're using EL 2.2 (your question history confirms this), then you can just use Set#toArray() to convert it to an array and then use the brace notation [] to access the element by index. The below example prints the second item of the array representation of the #{bean.someSet}.
#{bean.someSet.toArray()[1]}
Again, this makes no sense if it's an unordered set like HashSet.
Your problem is quite unclear, but JSF2 doesn't really support Set.
Components like ui:repeat or h:datatable always need a sort to display data, so your best choice will be to convert your Set to a List first.

Setting the Index of a Node in VirtualStringTree?

I am trying to change the index of a node, because there are some specific nodes that at all times needs to be at the bottom of my tree. I tried to change the Node.Index, but that did not change anything. So my question is: How do I change the Index of a PVirtualNode?
Thanks! - Jeff
To change the index of node A, find the node B that has the index you want A to have, and then call Tree.MoveTo(A, B, amInsertBefore, False). B and everything after it will shift down by one to make room for A, and their Index fields will be recalculated. This works even if A doesn't yet exist in the tree (such as just after calling MakeNewNode).
If you're using Index to associate each node with its corresponding data value in a list or array, then you'll find this largely ineffective for re-ordering the displayed values.
You canot change the index of a node. Normally when using VirtualStringTree you hold your data in your own data structure separate from the tree and access the data from the events.
You can also store data directly in the nodes (using a record), but I prefer the other approach because it keeps the logic out of the tree view.
For example, you could store the data in a list and access this list in the GetText handler (you can use Node.Index). Then, if you want to reorder the items, just reorder your list and everything else will happen automatically (you might have to call Invalidate on the tree).
Pseudocode:
Initializing:
Tree.RootNodeCount := MyList.Count;
In the GetTextevent:
NodeText := MyList [Node.Index];
Reordering:
Reorder (MyList);
Tree.Invalidate;
Given that you are still using the tree view control as a container, the ideal solution offered by Smasher is not available to you.
One rather obvious solution, given that your tree view has no hierarchy (i.e. it's a list) would be to use the Sort method with your own compare function (OnCompareNodes).
The other blindingly obvious strategy would be to add the node that you want at the bottom last. If you need to add other nodes later, then insert them above the special last node with InsertNode. This simple approach will probably suffice for the problem as you have described it.
TVirtualNode is a doubly-linked list, it's not a index-based structure: you change the index of a node by removing it and adding it where you want it.
Look into DeleteNode and AddChild.

Resources