public TableType generateDefaultTable(String gid) { final TableType table = new TableType(); table.setId(gid); table.setTitle(ILMLCoreConstants.TITLE_PREFIX + gid); final ContentType ct = ContentType.fromValue(ILguiItem.CONTENT_JOBS); table.setContenttype(ct); for (final ColumnlayoutType columnLayout : lguiItem.getLayoutAccess().getTableLayout(gid).getColumn()) { if (columnLayout.isActive()) { final ColumnType column = new ColumnType(); column.setId(columnLayout.getCid()); column.setName(columnLayout.getKey()); generateDefaultSorting(column); if (columnLayout.getKey().equals(ILguiItem.JOB_STATUS)) { column.setType(ITableColumnLayout.COLUMN_TYPE_MANDATORY); if (gid.equals(ILMLCoreConstants.ID_ACTIVE_JOBS_VIEW)) { generateDefaultPattern(JobStatusData.RUNNING, ILMLCoreConstants.EQ, columnLayout); } else { generateDefaultPattern(JobStatusData.RUNNING, ILMLCoreConstants.NEQ, columnLayout); } } table.getColumn().add(column); } } jaxbUtil.addTable(lgui, table); return table; }
public String[] getTableColumnTitles(String gid) { if (lguiItem == null && lguiItem.getLayoutAccess() == null) { return null; } final ColumnlayoutType[] layoutColumns = lguiItem.getLayoutAccess().getLayoutColumsToCids(getCidsActiveColumns(gid), gid); final List<String> titles = new ArrayList<String>(); for (final ColumnlayoutType layoutColumn : layoutColumns) { if (layoutColumn.getKey() != null) { titles.add(layoutColumn.getKey()); } } return titles.toArray(new String[titles.size()]); }
/** * Get the column layout for the table * * @param gid ID of the table layout * @return column layout */ public ITableColumnLayout[] getTableColumnLayout(String gid) { if (lguiItem == null && lguiItem.getLayoutAccess() == null) { return new ITableColumnLayout[0]; } final BigInteger[] cids = getCids(gid); // layoutColumns are sorted by cids final ColumnlayoutType[] layoutColumns = lguiItem.getLayoutAccess().getLayoutColumsToCids(cids, gid); final ITableColumnLayout[] tableColumnLayouts = new ITableColumnLayout[layoutColumns.length]; for (int i = 0; i < layoutColumns.length; i++) { final ColumnlayoutType column = layoutColumns[i]; if (column != null) { String style = null; final String sort = getColumnSortProperty(getTable(gid), cids, i); // when there is a change if (column.getSorted() != null && column.getSorted().value() != null && sort != null) { if (sort.equals(ILMLCoreConstants.TABLECOLUMN_NUMERIC)) { style = ITableColumnLayout.COLUMN_STYLE_RIGHT; } else if (sort.equals(ILMLCoreConstants.TABLECOLUMN_ALPHA)) { style = ITableColumnLayout.COLUMN_STYLE_LEFT; } else { style = ITableColumnLayout.COLUMN_STYLE_CENTER; } } tableColumnLayouts[i] = new TableColumnLayout( column.getKey(), column.getWidth(), style, column.isActive(), sort); } } return tableColumnLayouts; }
public void setTableColumnActive(String gid, String text, boolean activeTableColumn) { final List<ColumnlayoutType> columnLayouts = lguiItem.getLayoutAccess().getTableLayout(gid).getColumn(); for (final ColumnlayoutType column : columnLayouts) { if (column.getKey().equals(text)) { column.setActive(activeTableColumn); break; } } }
public void deleteOldPattern(String gid, List<String> columnsTitle) { final TablelayoutType tablelayout = lguiItem.getLayoutAccess().getTableLayout(gid); if (tablelayout != null) { for (final ColumnlayoutType column : tablelayout.getColumn()) { for (final String columnTitle : columnsTitle) { if (column.getKey().equals(columnTitle)) { column.setPattern(null); } } } } }
public void generateNewPattern(String gid, List<IPattern> filterValues) { final TablelayoutType tablelayout = lguiItem.getLayoutAccess().getTableLayout(gid); if (tablelayout != null) { for (final ColumnlayoutType column : tablelayout.getColumn()) { for (final IPattern filterValue : filterValues) { if (column.getKey().equals(filterValue.getColumnTitle())) { final PatternType pattern = new PatternType(); if (filterValue.isRange()) { final SelectType selectMin = new SelectType(); selectMin.setRel(ILMLCoreConstants.xGE_LC); selectMin.setValue(filterValue.getMinValueRange()); final SelectType selectMax = new SelectType(); selectMax.setRel(ILMLCoreConstants.xLE_LC); selectMax.setValue(filterValue.getMaxValueRange()); jaxbUtil.addPatternSelect(pattern, selectMin); jaxbUtil.addPatternSelect(pattern, selectMax); } else { final SelectType select = new SelectType(); select.setValue(filterValue.getRelationValue()); if (filterValue.getRelationOperator().equals(ILMLCoreConstants.LT)) { select.setRel(ILMLCoreConstants.xLT_LC); } else if (filterValue.getRelationOperator().equals(ILMLCoreConstants.LE)) { select.setRel(ILMLCoreConstants.xLE_LC); } else if (filterValue.getRelationOperator().equals(ILMLCoreConstants.GT)) { select.setRel(ILMLCoreConstants.xGT_LC); } else if (filterValue.getRelationOperator().equals(ILMLCoreConstants.GE)) { select.setRel(ILMLCoreConstants.xGE_LC); } else { select.setRel(filterValue.getRelationOperator()); } jaxbUtil.addPatternSelect(pattern, select); } column.setPattern(pattern); } } } } }
/** * Reading out the select patterns from the JAXB objects. * * <p>Also taking care of the switch between the operators on the client side and in the LML file. * * @param gid Id of the table from which we want to get the list of patterns. * @return List of select patterns */ public List<IPattern> getPattern(String gid) { // Expects both elements to be available table and tablelayout // Requires sort datatype from table and pattern from tablelayout final TablelayoutType tablelayout = lguiItem.getLayoutAccess().getTableLayout(gid); final TableType table = getTable(gid); final LinkedList<IPattern> patternList = new LinkedList<IPattern>(); // Avoid null values if (tablelayout == null || table == null) { return patternList; } final HashMap<ColumnlayoutType, ColumnType> columnLayoutToColumn = new HashMap<ColumnlayoutType, ColumnType>(); // Search column for each columnlayout for (final ColumnlayoutType columnLayout : tablelayout.getColumn()) { for (final ColumnType aColumn : table.getColumn()) { // Search for columnlayout referencing to the column's ID if (aColumn.getId().intValue() == columnLayout.getCid().intValue()) { columnLayoutToColumn.put(columnLayout, aColumn); break; } } } for (final ColumnlayoutType columnLayout : tablelayout.getColumn()) { final ColumnType column = columnLayoutToColumn.get(columnLayout); if (column != null && columnLayout != null && columnLayout.getPattern() != null) { final List<SelectType> selects = jaxbUtil.getSelects(columnLayout.getPattern().getIncludeAndExcludeAndSelect()); if (selects.size() == 1) { String rel = null; if (selects.get(0).getRel().equals(ILMLCoreConstants.xLT_LC)) { rel = ILMLCoreConstants.LT; } else if (selects.get(0).getRel().equals(ILMLCoreConstants.xLE_LC)) { rel = ILMLCoreConstants.LE; } else if (selects.get(0).getRel().equals(ILMLCoreConstants.xGT_LC)) { rel = ILMLCoreConstants.GT; } else if (selects.get(0).getRel().equals(ILMLCoreConstants.xGE_LC)) { rel = ILMLCoreConstants.GE; } else { rel = selects.get(0).getRel(); } if (rel != null) { patternList.add( (new Pattern(columnLayout.getKey(), column.getSort().value())) .setRelation(rel, selects.get(0).getValue())); } } else if (selects.size() == 2) { String minValue = null; String maxValue = null; for (final SelectType select : selects) { if (select.getRel().equals(ILMLCoreConstants.xLE_LC)) { maxValue = select.getValue(); } else if (select.getRel().equals(ILMLCoreConstants.xGE_LC)) { minValue = select.getValue(); } } if (minValue != null && maxValue != null) { patternList.add( (new Pattern(columnLayout.getKey(), column.getSort().value())) .setRange(minValue, maxValue)); } } } } return patternList; }