Class AbstractScesimGridModel<T extends org.drools.scenariosimulation.api.model.AbstractScesimModel<E>,​E extends org.drools.scenariosimulation.api.model.AbstractScesimData>

  • All Implemented Interfaces:
    org.uberfire.ext.wires.core.grids.client.model.GridData
    Direct Known Subclasses:
    BackgroundGridModel, ScenarioGridModel

    public abstract class AbstractScesimGridModel<T extends org.drools.scenariosimulation.api.model.AbstractScesimModel<E>,​E extends org.drools.scenariosimulation.api.model.AbstractScesimData>
    extends org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData
    Abstract BaseGridData to be extended by actual implementations (Simulation and Background)
    • Constructor Detail

      • AbstractScesimGridModel

        public AbstractScesimGridModel()
      • AbstractScesimGridModel

        public AbstractScesimGridModel​(boolean isMerged)
    • Method Detail

      • getGridWidget

        public abstract GridWidget getGridWidget()
      • bindContent

        public void bindContent​(T abstractScesimModel)
        Method to bind the data serialized inside backend AbstractScesimModel
        Parameters:
        abstractScesimModel -
      • setEventBus

        public void setEventBus​(com.google.gwt.event.shared.EventBus eventBus)
      • nextColumnCount

        public int nextColumnCount()
      • destroyAllTextAreaDOMElementFactoryResources

        public void destroyAllTextAreaDOMElementFactoryResources()
        It detaches all DomElement resources for selected DOMElementFactorys
      • appendRow

        public void appendRow​(org.uberfire.ext.wires.core.grids.client.model.GridRow row)
        This method append a new row to the grid and to the underlying model
        Specified by:
        appendRow in interface org.uberfire.ext.wires.core.grids.client.model.GridData
        Overrides:
        appendRow in class org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData
        Parameters:
        row -
      • insertRowGridOnly

        public abstract void insertRowGridOnly​(int rowIndex,
                                               org.uberfire.ext.wires.core.grids.client.model.GridRow row,
                                               E abstractScesimData)
        This method insert a row to the grid and populate it with values taken from given AbstractScesimData
        Parameters:
        row -
      • insertRowGridOnly

        public void insertRowGridOnly​(int rowIndex,
                                      org.uberfire.ext.wires.core.grids.client.model.GridRow row)
        This method insert a row to the grid
        Parameters:
        row -
      • insertRow

        public void insertRow​(int rowIndex,
                              org.uberfire.ext.wires.core.grids.client.model.GridRow row)
        This method insert a new row to the grid and to the underlying model
        Specified by:
        insertRow in interface org.uberfire.ext.wires.core.grids.client.model.GridData
        Overrides:
        insertRow in class org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData
        Parameters:
        row -
      • deleteRow

        public org.uberfire.ext.wires.core.grids.client.model.GridData.Range deleteRow​(int rowIndex)
        This method delete the row at the given index from both the grid and the underlying model
        Specified by:
        deleteRow in interface org.uberfire.ext.wires.core.grids.client.model.GridData
        Overrides:
        deleteRow in class org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData
        Parameters:
        rowIndex -
      • duplicateRow

        public void duplicateRow​(int rowIndex,
                                 org.uberfire.ext.wires.core.grids.client.model.GridRow row)
        This method duplicate the row at the given index from both the grid and the underlying model and insert just below the original one
        Parameters:
        rowIndex -
      • duplicateColumnValues

        public void duplicateColumnValues​(int originalColumnIndex,
                                          int newColumnIndex)
        This method duplicates the row values at the source column index from both the grid and the underlying model and inserts at the target column index
        Parameters:
        originalColumnIndex -
        newColumnIndex -
      • insertColumnGridOnly

        public void insertColumnGridOnly​(int index,
                                         org.uberfire.ext.wires.core.grids.client.model.GridColumn<?> column)
        This method insert a new column to the grid without modify underlying model
        Parameters:
        index -
        column -
      • insertColumn

        public void insertColumn​(int index,
                                 org.uberfire.ext.wires.core.grids.client.model.GridColumn<?> column)
        This method insert a new column to the grid and to the underlying model
        Specified by:
        insertColumn in interface org.uberfire.ext.wires.core.grids.client.model.GridData
        Overrides:
        insertColumn in class org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData
        Parameters:
        index -
        column -
      • deleteColumn

        public void deleteColumn​(int columnIndex)
        This method delete the column at the given index from both the grid and the underlying model
        Parameters:
        columnIndex -
      • deleteInstance

        public void deleteInstance​(int columnIndex)
        This method delete the whole instance of the column at the given index from both the grid and the underlying model
        Parameters:
        columnIndex -
      • updateColumnInstance

        public void updateColumnInstance​(int columnIndex,
                                         org.uberfire.ext.wires.core.grids.client.model.GridColumn<?> column)
        This method update the instance mapped inside a given column
        Parameters:
        columnIndex -
        column -
      • updateColumnProperty

        public void updateColumnProperty​(int columnIndex,
                                         org.uberfire.ext.wires.core.grids.client.model.GridColumn<?> column,
                                         List<String> propertyNameElements,
                                         String lastLevelClassName,
                                         boolean keepData,
                                         org.drools.scenariosimulation.api.model.FactMappingValueType valueType,
                                         org.drools.scenariosimulation.api.model.ScenarioSimulationModel.Type type)
        This method update the type mapped inside a give column and updates the underlying model
        Parameters:
        columnIndex -
        column -
        propertyNameElements -
        lastLevelClassName -
        keepData -
      • replaceColumn

        protected void replaceColumn​(int columnIndex,
                                     org.uberfire.ext.wires.core.grids.client.model.GridColumn<?> column)
        This method replace a column at columnIndex position with a new column. It also save and restore width of the columns
        Parameters:
        columnIndex -
        column -
      • setCellGridOnly

        public org.uberfire.ext.wires.core.grids.client.model.GridData.Range setCellGridOnly​(int rowIndex,
                                                                                             int columnIndex,
                                                                                             Supplier<org.uberfire.ext.wires.core.grids.client.model.GridCell<?>> cellSupplier)
        This method set a cell value to the grid without modify underlying model
        Parameters:
        rowIndex -
        columnIndex -
        cellSupplier -
      • setCell

        public org.uberfire.ext.wires.core.grids.client.model.GridData.Range setCell​(int rowIndex,
                                                                                     int columnIndex,
                                                                                     Supplier<org.uberfire.ext.wires.core.grids.client.model.GridCell<?>> cellSupplier)
        This method set a cell value to the grid and to the underlying model
        Specified by:
        setCell in interface org.uberfire.ext.wires.core.grids.client.model.GridData
        Overrides:
        setCell in class org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData
        Parameters:
        rowIndex -
        columnIndex -
        cellSupplier -
      • setCellValue

        public org.uberfire.ext.wires.core.grids.client.model.GridData.Range setCellValue​(int rowIndex,
                                                                                          int columnIndex,
                                                                                          org.uberfire.ext.wires.core.grids.client.model.GridCellValue<?> value)
        Specified by:
        setCellValue in interface org.uberfire.ext.wires.core.grids.client.model.GridData
        Overrides:
        setCellValue in class org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData
      • deleteCell

        public org.uberfire.ext.wires.core.grids.client.model.GridData.Range deleteCell​(int rowIndex,
                                                                                        int columnIndex)
        Specified by:
        deleteCell in interface org.uberfire.ext.wires.core.grids.client.model.GridData
        Overrides:
        deleteCell in class org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData
      • getInstanceLimits

        public abstract org.uberfire.ext.wires.core.grids.client.model.GridData.Range getInstanceLimits​(int columnIndex)
        This methods returns the Range of a single block of columns of the same instance/data object. A single block is made of all the columns immediately to the left and right of the selected one with the same "label". If there is another column with the same "label" but separated by a different column, it is not part of the group.
        Parameters:
        columnIndex -
        Returns:
      • getInstanceScenarioGridColumns

        public List<ScenarioGridColumn> getInstanceScenarioGridColumns​(int columnIndex)
        This methods returns the List<ScenarioGridColumn> of a single block of columns of the same instance/data object. A single block contains the selected column and all the columns immediately to the left and right of it with the same "label". If there is another column with the same "label" but separated by a different column, it is not part of the group.
        Parameters:
        columnIndex -
        Returns:
      • getInstanceScenarioGridColumns

        public List<ScenarioGridColumn> getInstanceScenarioGridColumns​(ScenarioGridColumn selectedColumn)
        This methods returns the List<ScenarioGridColumn> of a single block of columns of the same instance/data object. A single block contains the selected column and all the columns immediately to the left and right of it with the same "label". If there is another column with the same "label" but separated by a different column, it is not part of the group.
        Parameters:
        selectedColumn -
        Returns:
      • getFirstIndexLeftOfGroup

        public int getFirstIndexLeftOfGroup​(String groupName)
        Return the first index to the left of the given group, i.e. excluded the left-most index of that group
        Parameters:
        groupName -
        Returns:
      • getFirstIndexRightOfGroup

        public int getFirstIndexRightOfGroup​(String groupName)
        Return the first index to the right of the given group, i.e. excluded the right-most index of that group
        Parameters:
        groupName -
        Returns:
      • getGroupSize

        public long getGroupSize​(String groupName)
        Returns how many columns are already in place for the given group
        Parameters:
        groupName -
        Returns:
      • getInstancesCount

        public int getInstancesCount​(String className)
        Returns the count of instantiated facts given a classname.
        Parameters:
        className -
        Returns:
      • updateHeader

        public void updateHeader​(int columnIndex,
                                 int headerRowIndex,
                                 String headerCellValue)
      • clear

        public void clear()
      • clearSelections

        public void clearSelections()
        Specified by:
        clearSelections in interface org.uberfire.ext.wires.core.grids.client.model.GridData
        Overrides:
        clearSelections in class org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData
      • forceRefreshWidth

        public boolean forceRefreshWidth()
        It forces a internalRefreshWidth refresh
      • synchronizeFactMappingsWidths

        public void synchronizeFactMappingsWidths()
        It synchronizes all columns related factMapping columnnWidths
      • synchronizeFactMappingWidth

        public void synchronizeFactMappingWidth​(org.uberfire.ext.wires.core.grids.client.model.GridColumn<?> column)
        It updates a column related factMapping columnWidth
        Parameters:
        column -
      • loadFactMappingsWidth

        public void loadFactMappingsWidth()
        It retrieves the stored columnWidths and assigns them to every grid column.
      • selectColumn

        public void selectColumn​(int columnIndex)
        It puts the column present in the given columnIndex as the current selected one.
        Parameters:
        columnIndex -
      • selectRow

        public void selectRow​(int rowIndex)
        Select all the cells of the given row
        Parameters:
        rowIndex -
      • getSelectedColumn

        public org.uberfire.ext.wires.core.grids.client.model.GridColumn<?> getSelectedColumn()
      • getAbstractScesimModel

        public Optional<T> getAbstractScesimModel()
      • isSelectedColumnEmpty

        public boolean isSelectedColumnEmpty()
        Returns true if all the grid cells of the selected column are empty, i.e. the GridCell.getValue() == null OR GridCell.getValue().getValue() == null
        Returns:
      • isColumnEmpty

        public boolean isColumnEmpty​(int columnIndex)
        Returns true if all the grid cells of the column at given index are empty, i.e. the GridCell.getValue() == null OR GridCell.getValue().getValue() == null
        Parameters:
        columnIndex -
        Returns:
      • isAlreadyAssignedProperty

        public boolean isAlreadyAssignedProperty​(List<String> propertyNameElements)
        Returns true if property mapped to the selected column is already assigned to another column of the same instance
        Parameters:
        propertyNameElements -
        Returns:
      • checkAlreadyAssignedProperty

        public void checkAlreadyAssignedProperty​(int columnIndex,
                                                 List<String> propertyNameElements)
        Check if property mapped to the column at given index is already assigned to another column of the same instance
        Parameters:
        columnIndex -
        propertyNameElements -
        Throws:
        IllegalStateException - if the given propertyNameElements are already mapped to a column of the same instance
      • isSameSelectedColumnProperty

        public boolean isSameSelectedColumnProperty​(List<String> propertyNameElements,
                                                    org.drools.scenariosimulation.api.model.FactMappingValueType factMappingValueType)
        Returns true if property mapped to the selected column is the same as the provided one
        Parameters:
        propertyNameElements -
        factMappingValueType -
        Returns:
      • isSameSelectedColumnProperty

        public boolean isSameSelectedColumnProperty​(int columnIndex,
                                                    List<String> propertyNameElements,
                                                    org.drools.scenariosimulation.api.model.FactMappingValueType factMappingValueType)
        Returns true if property mapped to the column at given index is the same as the provided one
        Parameters:
        columnIndex -
        propertyNameElements -
        factMappingValueType -
        Returns:
      • isSameSelectedColumnType

        public boolean isSameSelectedColumnType​(String className)
        Returns true if no column is selected OR if type of the property mapped to the selected column is the same as the provided one
        Parameters:
        className -
        Returns:
      • isSameSelectedColumnType

        public boolean isSameSelectedColumnType​(int columnIndex,
                                                String className)
        Returns true if type of the property mapped to the column at given index is the same as the provided one
        Parameters:
        columnIndex -
        className -
        Returns:
      • isSameInstanceType

        public boolean isSameInstanceType​(String className)
        Returns true if no column is selected OR if type of the INSTANCE mapped to the selected column is the same as the provided one
        Parameters:
        className -
        Returns:
      • checkSameInstanceHeader

        public void checkSameInstanceHeader​(int columnIndex,
                                            String headerName)
        Check if given headerName is the same as the Fact mapped to the column at given index
        Parameters:
        columnIndex -
        headerName -
        Throws:
        IllegalStateException - if the given headerName is not the name of the class mapped to the given column
      • isSameInstanceType

        public boolean isSameInstanceType​(int columnIndex,
                                          String headerName)
        Returns true if type of the INSTANCE mapped to the column at given index is the same as the provided one
        Parameters:
        columnIndex -
        headerName -
        Returns:
      • checkSamePropertyHeader

        public void checkSamePropertyHeader​(int columnIndex,
                                            List<String> propertyNameElements)
        Check if given headerName is the same as the element steps mapped to the given column
        Parameters:
        columnIndex -
        propertyNameElements -
        Throws:
        IllegalStateException - if the given propertyNameElements (corrected for the class name) represents the element steps of the given column
      • resetErrors

        public void resetErrors()
        It resets the FactMappingValue status for all CELLS
      • resetErrors

        public void resetErrors​(int rowIndex)
        It resets the FactMappingValue status for a specific ROW
        Parameters:
        rowIndex -
      • resetError

        public void resetError​(int rowIndex,
                               int columnIndex)
        It resets the FactMappingValue status for a specific CELL
        Parameters:
        rowIndex -
        columnIndex -
      • refreshErrors

        public void refreshErrors()
      • setSimpleJavaTypeInstancesName

        public void setSimpleJavaTypeInstancesName​(Set<String> simpleJavaTypeInstancesName)
        Set the names of already existing Simple Java Types/Instances, used inside updateHeaderValidation
        Parameters:
        simpleJavaTypeInstancesName -
      • validateInstanceHeaderUpdate

        public void validateInstanceHeaderUpdate​(String instanceHeaderCellValue,
                                                 int columnIndex,
                                                 boolean isADataType)
        Check validity of given instanceHeaderCellValue
        Parameters:
        instanceHeaderCellValue -
        columnIndex -
        isADataType -
        Throws:
        Exception - with message specific to failed check
      • validatePropertyHeaderUpdate

        public void validatePropertyHeaderUpdate​(String propertyHeaderCellValue,
                                                 int columnIndex,
                                                 boolean isPropertyType)
        Check validity of given propertyHeaderCellValue
        Parameters:
        propertyHeaderCellValue -
        columnIndex -
        isPropertyType -
        Throws:
        Exception - with message specific to failed check
      • isSimpleType

        public boolean isSimpleType​(String factClassName)
      • getInstanceLimits

        protected org.uberfire.ext.wires.core.grids.client.model.GridData.Range getInstanceLimits​(int columnIndex,
                                                                                                  int columnIndexStart)
        This methods returns the Range of a single block of columns of the same instance/data object. A single block is made of all the columns immediately to the left and right of the selected one with the same "label". If there is another column with the same "label" but separated by a different column, it is not part of the group.
        Parameters:
        columnIndex -
        columnIndexStart - the leftmost index to consider when evaluating the range
        Returns:
      • updateFactMapping

        protected void updateFactMapping​(org.drools.scenariosimulation.api.model.ScesimModelDescriptor simulationDescriptor,
                                         org.drools.scenariosimulation.api.model.FactMapping factMappingReference,
                                         int index,
                                         String value,
                                         ScenarioHeaderMetaData.MetadataType metadataType)
        If the FactIdentifier of the given FactMapping equals the one at index, update the FactMapping.FactAlias at index position with the provided value
        Parameters:
        simulationDescriptor -
        factMappingReference -
        index -
        value -
      • commonAddColumn

        protected void commonAddColumn​(int index,
                                       org.uberfire.ext.wires.core.grids.client.model.GridColumn<?> column)
        This method add or insert a new column to the grid and to the underlying model, depending on the index value. If index == -1 -> add, otherwise insert. It automatically creates default FactIdentifier (for String class) and ExpressionIdentifier
        Parameters:
        index -
        column -
      • commonAddColumn

        protected void commonAddColumn​(int index,
                                       org.uberfire.ext.wires.core.grids.client.model.GridColumn<?> column,
                                       org.drools.scenariosimulation.api.model.ExpressionIdentifier ei)
        This method add or insert a new column to the grid and to the underlying model, depending on the index value. If index == -1 -> add, otherwise insert.
        Parameters:
        index -
        column -
        ei -
      • commonAddRow

        protected abstract void commonAddRow​(int rowIndex)
      • commonAddRow

        protected void commonAddRow​(int rowIndex,
                                    int columnIndexStart)
      • updateIndexColumn

        protected void updateIndexColumn()
      • checkSimulation

        protected void checkSimulation()
      • checkValidAndUniqueInstanceHeaderTitle

        protected void checkValidAndUniqueInstanceHeaderTitle​(String instanceHeaderCellValue,
                                                              int columnIndex)
        Verify the given value is not already used as instance header name between different groups
        Parameters:
        instanceHeaderCellValue -
        columnIndex -
        Throws:
        IllegalArgumentException - if the given instanceHeaderCellValue contains a dot OR it has already been used inside the group (GIVEN/EXPECT) of the given column
      • checkValidAndUniquePropertyHeaderTitle

        protected void checkValidAndUniquePropertyHeaderTitle​(String propertyHeaderCellValue,
                                                              int columnIndex)
        Verify if the given value is not already used as property header name inside the same instance
        Parameters:
        propertyHeaderCellValue -
        columnIndex -
        Throws:
        IllegalArgumentException - if the given propertyHeaderCellValue contains a dot OR it has already been used inside the instance of the given column
      • checkUniquePropertyHeaderTitle

        protected void checkUniquePropertyHeaderTitle​(String propertyHeaderCellValue,
                                                      int columnIndex)
        Verify if the given value is not already used as property header name inside the same instance
        Parameters:
        propertyHeaderCellValue -
        columnIndex -
        Throws:
        IllegalArgumentException - if the given propertyHeaderCellValue has already been used inside the instance of the given column
      • isNewInstanceName

        protected boolean isNewInstanceName​(String value)
      • isNewPropertyName

        protected boolean isNewPropertyName​(String value)
      • refreshErrorsRow

        protected void refreshErrorsRow​(int rowIndex)
      • getDOMElementFactory

        public org.uberfire.ext.wires.core.grids.client.widget.dom.single.impl.BaseSingletonDOMElementFactory getDOMElementFactory​(String className,
                                                                                                                                   org.drools.scenariosimulation.api.model.ScenarioSimulationModel.Type modelType,
                                                                                                                                   org.drools.scenariosimulation.api.model.FactMappingValueType valueType)
        Returns the correct DOMElement factory to the given data
        Parameters:
        modelType -
        valueType -