Beispiel #1
0
def fdnDefaultReset():
    from Spotfire.Dxp.Application.Scripting import ScriptDefinition
    from System.Collections.Generic import Dictionary
    import Spotfire.Dxp.Application.Filters as filters
    import clr

    # 1. Reset all Filters
    for scheme in Document.FilteringSchemes:
        scheme.ResetAllFilters()

    # 2. Reset all Markings
    # Loop through each data table
    for dataTable in Document.Data.Tables:
        # Navigate through each marking in a given data table
        for marking in Document.Data.Markings:
            # Unmark the selection
            rows = RowSelection(IndexSet(dataTable.RowCount, False))
            marking.SetSelection(rows, dataTable)

    # 3. Execute Custom Function of Developers:
    scriptDefinition = clr.Reference[ScriptDefinition]()
    Document.ScriptManager.TryGetScript("βFoundationCustom", scriptDefinition)
    parameters = Dictionary[str, object]()
    Document.ScriptManager.ExecuteScript(scriptDefinition.ScriptCode,
                                         parameters)
Beispiel #2
0
def tag_Marked_Items(tableName, colName, tagName):
    # Return: 			No return object(s)
    # Last updated:		6/30/18
    # Created by: 	    Tyler Hunt
    #
    # 1.0 - Create a reference to the targeted column
    # 2.0 - Creates a filter to only the marked row in the table
    # 3.0 - Finally, it tags the marked item(s) in the table
    # 	3.1 - Tag the filtered data set with the
    # 	3.2 - Print confirmation message(s)

    # 1.0 - Create reference to the tags column
    tagsCol = tableName.Columns[colName].As[TagsColumn]()

    # 2.0 - Get the marked rows
    filteringRowSelection = Document.ActiveMarkingSelectionReference.GetSelection(
        tableName)
    filteredSet = IndexSet(filteringRowSelection.AsIndexSet())

    timeUpdated = datetime.datetime.now().strftime("%m-%d-%Y %H:%M:%S")

    # 3.0 - Check if index set is empty
    if filteredSet.Count > 0:
        # 3.1 - Tag the filtered data set with the
        tagsCol.Tag(tagName, RowSelection(filteredSet))

        # 3.2 - Print confirmation message
        print('Tag(s) have been created successfully @ ' + timeUpdated)
    else:
        # 3.2 - Print confirmation message
        print('No tag(s) have been created @ ' + timeUpdated)
Beispiel #3
0
def findrowfilter(table):
    from Spotfire.Dxp.Data import IndexSet
    """Returns number of rows in a table
    args:
       table (spotfire table instance): table to find rows from
    """
    #Identify the number of rows in the data table
    count = table.RowCount
    rowfilter = IndexSet(count, False)
    return rowfilter
Beispiel #4
0
def clear_Markings(markingName, tableName):
    # Return: 			No return object(s)
    # Last updated:		6/30/18
    # Created by: 	    Tyler Hunt
    #
    # 1.0 - Create reference to the markings
    # 2.0 - Create index set on the current table reference
    # 3.0 - Creates a cursor for the marked items in the table

    # 1.0 - Create reference to the markings
    marking = Application.GetService[DataManager]().Markings[markingName]

    # 2.0 - Create index set on the current table reference
    selectRows = IndexSet(tableName.RowCount, False)

    # 3.0 - Clar the markingon the table
    marking.SetSelection(RowSelection(selectRows), tableName)
    print('Marking(s) have been cleared')
Beispiel #5
0
def fdnConfigNavigationToJSON():
    reportId = Document.Properties["fdnReportId"]

    import clr
    import sys
    import json
    clr.AddReference('System.Web.Extensions')
    from System.Web.Script.Serialization import JavaScriptSerializer
    from Spotfire.Dxp.Data import IndexSet
    from Spotfire.Dxp.Data import DataValueCursor

    for eTable in Document.Data.Tables:
        if eTable.Name in ['fdnConfig', 'fdnNavigation']:
            rowCount = eTable.RowCount
            rows = IndexSet(rowCount, True)
            cols = eTable.Columns
            fdnData = []

            for r in rows:
                list = {}
                item = {}
                for c in cols:
                    item[c.Name] = c.RowValues.GetFormattedValue(r)
                    list[eTable.Name] = item
                # add Spotfire Environment Information to fdnConfig
                if eTable.Name == 'fdnConfig':
                    item[
                        "SPOTFIRE_ENVIRONMENT"] = fdnDetectSpotfireEnvironment(
                        )
                    list[eTable.Name] = item
                # Add data only if the "REPORT_ID" matches the "fdnReportId" Doc. Prop.:
                if reportId == list[eTable.Name]["REPORT_ID"]:
                    fdnData.append(list)

            fdnDataOutput = json.dumps(fdnData)
            Document.Properties[eTable.Name] = fdnDataOutput
Beispiel #6
0
from Spotfire.Dxp.Data import DataManager
from Spotfire.Dxp.Data import IndexSet
from Spotfire.Dxp.Data import RowSelection

marking = Application.GetService[DataManager]().Markings[markingName]
selectRows = IndexSet(dataTable.RowCount, False)
marking.SetSelection(RowSelection(selectRows), dataTable)
#Laurent Cesaro

#Import library
from Spotfire.Dxp.Data import RowSelection, IndexSet

selection = IndexSet(dt.RowCount, True)
for r in selection:
    selection[r] = (r <= 100)

#delete rows based on selection (rows from indexset marked as true)
dt.RemoveRows(RowSelection(selection))
Beispiel #8
0
from Spotfire.Dxp.Data import DataColumn, TagsColumn
from Spotfire.Dxp.Data import DataPropertyClass, DataType, DataValueCursor, IDataColumn, IndexSet
from Spotfire.Dxp.Data import RowSelection

# Tag the marked rows
markedRowSelection = Document.ActiveMarkingSelectionReference.GetSelection(
    Document.ActiveDataTableReference)
table = Document.ActiveDataTableReference
myTagColumn = table.Columns.Item["Decision"].As[TagsColumn]()

selectRows = IndexSet(table.RowCount, True)
myTagColumn.Tag("No", RowSelection(selectRows))
myTagColumn.Tag("Yes", markedRowSelection)
Beispiel #9
0
def tag_bhaSelectedItems(columnName, tableName, bha_SelectedWells):
    # Return: 			list of bha's selected
    # Last updated:		6/30/18
    # Created by: 	    Tyler Hunt
    #
    # 1.0 - Create cursor to the bha selected marker
    # 2.0 - Create references to the bha table row count, rows to include and rows to mark
    # 3.0 - Loop thru the selected wells and add bhaSelected tag to wellsTable
    # 	3.1 - Loop through the selcted well bha list
    # 	3.2 - Loop through the wellsTable and mark the bha selected pn in wellsTable
    # 4.0 - Reference to the Tag Column
    # 5.0 - Get the marked rows
    # 	5.1 - Tag the filtered data set with the
    # 	5.2 - Print confirmation message(2)

    # 1.0 - Create cursor to the bha selected marker
    cursor_WellsPN = DataValueCursor.CreateFormatted(
        wellsTable.Columns['alt_well_pn'])

    # 2.0 - Create references to the bha table row count, rows to include and rows to mark
    rowCount = wellsTable.RowCount
    rowsToInclude = IndexSet(rowCount, True)
    rowsToMark = IndexSet(rowCount, False)

    # 3.0 - Loop thru the selected wells and add bhaSelected tag to wellsTable
    if not bha_SelectedWells:
        pass
    else:
        # 3.1 - Loop through the selcted well bha list
        for bhaPN in bha_SelectedWells:

            # 3.2 - Loop through the wellsTable and mark the bha selected pn in wellsTable
            for row in wellsTable.GetRows(cursor_WellsPN):
                rowIndex = row.Index
                wellsPN = cursor_WellsPN.CurrentValue

                # 3.3 - Mark well in wells table
                # TODO: Might need to check the Selcted status????
                if wellsPN == bhaPN:
                    rowsToMark.AddIndex(rowIndex)
                    Document.ActiveMarkingSelectionReference.SetSelection(
                        RowSelection(rowsToMark), wellsTable)

        # 4.0 - Reference to the Tag Column
        tagsCol = tableName.Columns[columnName].As[TagsColumn]()

        # Tag nname
        tagName = 'Selected'

        # Time updated
        timeUpdated = datetime.datetime.now().strftime("%m-%d-%Y %H:%M:%S")

        # 5.0 - Get the marked rows
        filteringRowSelection = Document.ActiveMarkingSelectionReference.GetSelection(
            tableName)
        filteredSet = IndexSet(filteringRowSelection.AsIndexSet())

        # 5.0 - Check if index set is empty
        if filteredSet.Count != 0:
            # 5.1 - Tag the filtered data set with the
            tagsCol.Tag(tagName, RowSelection(filteredSet))

            # 5.2 - Print confirmation message
            print('Bha Tag(s) have been created successfully @ ' + timeUpdated)
        else:
            # 5.2 - Print confirmation message
            print('No Bha tag(s) have been created @ ' + timeUpdated)