private void generateDefaultPattern(String value, String relation, ColumnlayoutType column) { final PatternType pattern = new PatternType(); final SelectType select = new SelectType(); select.setRel(relation); select.setValue(value); 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; }
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); } } } } }