/** * 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; }