In Spotfire, how to trellis a SummaryTable using IronPython script - spotfire

I am trying to "trellis" a summary table using a script. The TrellisVisualization is not available for the SummaryTable class. Using the GUI, I can trellis a summary table by assigning a specific column to the Categorization property under Columns Properties. However, while using the IronPython script, I don't see any property named Categorization for the SummaryTable object. So, I tried assigning the column to the CategoryAxis as follows:
mySummaryTable.CategoryAxis = "<[myColumn]>"
But this throws an error:
AttributeError: 'SummaryTable' object has no attribute 'CategoryAxis'
I also tried using Axis or CategoricalAxisBase etc. as properties, but these options did not work out. If anyone has more ideas on this, please let me know. Thanks.
RD

The key issue here is that the CategoryAxis property underneath the Summary Table class is a GET of this visual's object of the GroupByAxis class. You can see this by using the print command and getting information about the object:
print mySummaryTable.CategoryAxis
results in my Spotfire example:
<Spotfire.Dxp.Application.Visuals.GroupByAxis object at 0x000000000000002C [Spotfire.Dxp.Application.Visuals.GroupByAxis]>
You were actually quite close though. In order to set the CategoryAxis you need to set the Expression property of the CategoryAxis like so:
from Spotfire.Dxp.Application.Visuals import SummaryTable
mySummaryTable = myVisual.As[SummaryTable]()
mySummaryTable.CategoryAxis.Expression = "<[COLUMN]>"
If you need to pass an actual column name into that rather than hardcoded, I would concatenate the expression syntax and set the Expression equal to that variable:
myColumnExp = "<[" + myColumnName + "]>"
mySummaryTable.CategoryAxis.Expression = myColumnExp
Please let me know if you need any clarity regarding this. My Spotfire version for this answer is v6.5.2.26 and my API information from https://docs.tibco.com/pub/doc_remote/spotfire/6.5.0/api/Index.aspx

Related

Understanding Object Orientation Multiple Periods

I have a Object Oritentation quesation.
I have created the following Pandas series:-
import pandas as pd
my_series1 = pd.Series(data = [200,201,202,203], index = ["London", "New York", "London", "Sydney"], name = "Test")
my_series1 is an object from the Class series (I think)
my_series1 has access to methods and properties, one example of this is checking if all the values in the series are unique using the code:-
my_series1.is_unique
I am happy with the above code.
This is where things get confusing, I can check if the index values are also unique using the code:-
mmy_series1.index.is_unique
The code above does not make sense to me, I don't fully understand how the is_unique property can be applied to the index column - I have been assuming that once an object has been created you can access a method by calling the object name followed by a "." and then the name of the function.
This idea of multiple periods is confusing me as i cannot connect the is_unique back to how the class is created.
Also would it be correct to say the following:-
An object has attributes
An object has methods
But are properties of an object??, are object properties and methods the same thing?
Can anyone help?
Thank you.

How to organize a set of similar functions in two parallel chained-classes

I would like to obtain this set of properties with 1 class + 2 chained-classes:
mytable.EntireRange
mytable.DataBodyRange
mytable.HorizontalHeaderRange
mytable.VerticalHeaderRange
mytable.col(strTitle).num
mytable.col(strTitle).firstDataCell
mytable.col(strTitle).lastDataCell
mytable.row(strTitle).num
mytable.row(strTitle).firstDataCell
mytable.row(strTitle).lastDataCell
What's the best way to organize (and name) these classes and properties?
My current solution to add the chained properties is:
- I named the three classes "mytable", "mytable_col", "mytable_row" to keep a visible relationship in the Project Explorer
- inside "mytable", I added this:
Property Get col(strTitle As String) As mytable_col
Set col = New mytable_col
col.Initialize = Me ' passes the parent object
End Property
Property Get row(strTitle As String) As mytable_row
Set row = New mytable_row
row.Initialize = Me ' passes the parent object
End Property
Now... given that the three properties ("num", "firstDataCell", "lastDataCell") of the two parallel chained classes "col" and "row" share the same logic with little variations, I'd prefer to not put their complete code separated in 6 properties, three in the "row" class and three in the "col".
I ideally would to create just 3 properties/functions (passing a "row" or "col" as argument for the variations) instead than six.
How should I do? Is it possible, without to put them in an additional module?

How to identify the class of an Object which is in a cell of webtable

I have a webtable which MIGHT have a weblink object in it's Row 2, Column 1 cell (also Index of this object is 0). If it indeed is a link I would like to click it else ignore it. Is there a way to identify the class of this object given that we know the row and column number.
Below was my initial code. However it doesn't work always when the webtable cell doesn't have a link to click
Set Table = Browser("Oracle PeopleSoft").Page("Request Payment Predictor").WebTable("Run Control ID").ChildItem(2, 1, "Link", 0)
Table.Click
I would like to know if there a way to find the class of the Object (in cell of a web table) so I can click on the Object only if it's a link Or in other words can we use GetRoProperty("Class Name") on a WebTable Cell Object?
The ChildItem function returns a test object of the requested type if it exists, otherwise it returns Nothing.
So your code should look like this:
Set aLink = Browser("Oracle PeopleSoft")_
.Page("Request Payment Predictor")_
.WebTable("Run Control ID").ChildItem(2, 1, "Link", 0)
If Not aLink is Nothing Then
aLink.Click
End If
The object returned by ChildItem is a test object (if it's not Nothing) so you can use the regular test object methods on it.
Please note that the object returned is not a table cell object, it's the object of the type you requested, this type may be WebElement which is considered the base class of all web objects. This means that you can use ChildItem with "WebElement" and then see what actual type it is by getting its micClass (which is what the Class Name is called internally).
Print webElem.GetROProperty("micclass")
Pro tip: The indexes are 1 based, you can use the undocumented Highlight function in order to make sure you're working on the right object (obj.Highlight).

Get members of a group in Lotus Domino

I retrieve names from a group using formula, and put them in a field of type Names this way:
#Name([CN];NAME)
I want to manipulate this data in my code, but using Lotusscript. Can't find it at Google or Lotus Domino's Help. Is there a way I can handle this?
In LotusScript there is a class named "NotesName" to do such manipulations.
If there is a field named "NAME" in you document, then the code would look like:
Dim doc as NotesDocument
Dim nnName as NotesName
'Somehow get the document, using ws.CurrentDocument.document
'or db.UnprocessedDocments.GetFirstDocument, depends on your situation
Set nnName = New NotesName( doc.GetItemValue("NAME")(0) )
Whatyourlookingfor = nnName.Common
If NAME is a Multivalue then you would have to write a loop to get the common- name for every element in the array doc.GetItemValue("NAME")
The next time you have a question, check out the language cross reference in the help...
There it tells you, what the LotusScript- Pendant for #Name is.
Please try with below suggestion for getting list of person names from group.
First need to check the availability of searching group on names.nsf (All the groups are available on "($VIMGroups)" view.
if the group is available means you need to get the list of values from "Members" item
The members item have variant(list) values. So need to iterate the members for getting each value
Please refer the below sample code:
Set namesDb=session.GetDatabase(db.Server,"names.nsf")
Set groupVw=namesDb.GetView("($VIMGroups)")
Set groupDoc=groupvw.GetDocumentByKey("groupname")
persons= groupDoc.members
Forall person In persons
Msgbox person
End Forall
You can use the Evaluate method. It will return you the result of a Notes Formula:
Dim result as Variant
formula$ = "#Name([CN];NAME)"
result = Evaluate(formula$)
If the formula needs to be evaluated within the context of a document, you can pass that document as a second parameter to the method.
More info here

How to set blank space after a table in a docx document (working with apache poi)

I've been trying to create tables and make them to leave some space between its bottom border and whatever comes after the table (usually text).
As far as I have crawl through ooxml specification I understand that I need to add to the table this chain of elements tblPr (table properties) -> tblpPr (table position properties), and set the attribute bottomFromText to the specific amount space I want between the table and the next element, also the vertAnchor attribute (right now I'm configuring this with the "text" value) and finally the tblpY attribute.
A q&d snippet of what I'm doing is this (java and apache poi):
XWPFTable table = document.createTable();
CTTblPr _cttblpr = table.getCTTbl().addNewTblPr();
_cttblpr.addNewTblpPr().setBottomFromText(BigInteger.valueOf(284));
_cttblpr.getTblpPr().setVertAnchor(STVAnchor.TEXT);
_cttblpr.getTblpPr().setTblpY(BigInteger.valueOf(1));
My main reference has been this. Also I have been creating (with LibreOffice writer and Microsoft Office 2007) simple documents with just a table and the space I want and extracting the files inside it (word/document.xml specifically) to see in place this. All my efforts to achieve this have been unsuccessful by now.
Do you know what is wrong here? I strongly believe I have missconcepts...
Thank you in advance.
You're right, you need w:bottomFromText, for example:
<w:tbl>
<w:tblPr>
<w:tblpPr w:leftFromText="187" w:rightFromText="187" w:bottomFromText="4320" w:vertAnchor="text" w:tblpY="1"/>
<w:tblOverlap w:val="never"/>
</w:tblPr>
Based on the above, your code looks plausible.
For comparison, if you were doing it with docx4j, you'd create that in one of 2 ways.
The first way is to explicitly use the JAXB object factory:
org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory();
Tbl tbl = wmlObjectFactory.createTbl();
JAXBElement<org.docx4j.wml.Tbl> tblWrapped = wmlObjectFactory.createBodyTbl(tbl);
// Create object for tblPr
TblPr tblpr = wmlObjectFactory.createTblPr();
tbl.setTblPr(tblpr);
// Create object for tblpPr
CTTblPPr tblppr = wmlObjectFactory.createCTTblPPr();
tblpr.setTblpPr(tblppr);
tblppr.setLeftFromText( BigInteger.valueOf( 187) );
tblppr.setRightFromText( BigInteger.valueOf( 187) );
tblppr.setBottomFromText( BigInteger.valueOf( 4320) );
tblppr.setVertAnchor(org.docx4j.wml.STVAnchor.TEXT);
tblppr.setTblpY( BigInteger.valueOf( 1) );
// Create object for tblOverlap
CTTblOverlap tbloverlap = wmlObjectFactory.createCTTblOverlap();
tblpr.setTblOverlap(tbloverlap);
tbloverlap.setVal(org.docx4j.wml.STTblOverlap.NEVER);
The second is to unmarshall a string:
String openXML = "<w:tbl xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">
+ "<w:tblPr>
+ "<w:tblpPr w:bottomFromText=\"4320\" w:leftFromText=\"187\" w:rightFromText=\"187\" w:tblpY=\"1\" w:vertAnchor=\"text\"/>"
+ "<w:tblOverlap w:val=\"never\"/>"
+"</w:tblPr>"
etc
+"</w:tbl>";
Tbl tbl = (Tbl)XmlUtils.unmarshalString(openXML);

Resources