@Override public void write(Layout entity, JsonGenerator jg) throws IOException { jg.writeStartObject(); jg.writeStringField("name", entity.getName()); String type = entity.getType(); if (type != null) { jg.writeStringField("type", type); String typeCat = entity.getTypeCategory(); if (typeCat != null) { jg.writeStringField("typeCategory", typeCat); jg.writeStringField("mode", entity.getMode()); String template = entity.getTemplate(); if (template != null) { jg.writeStringField("template", template); Map<String, Serializable> properties = entity.getProperties(); if (MapUtils.isNotEmpty(properties)) { writeSerializableMapField("properties", properties, jg); LayoutRow[] lRows = entity.getRows(); if (lRows != null) { jg.writeArrayFieldStart("rows");
public static List<LayoutRow> getNotSelectedRows(Layout layout, List<String> selectedRowNames) { LayoutRow[] rows = layout.getRows(); List<LayoutRow> notSelectedRows = new ArrayList<LayoutRow>(); if (rows != null) { for (LayoutRow row : rows) { if (selectedRowNames == null && !row.isSelectedByDefault() && !row.isAlwaysSelected()) { notSelectedRows.add(row); } else if (selectedRowNames != null && !row.isAlwaysSelected() && !selectedRowNames.contains(row.getName())) { notSelectedRows.add(row); } } } return notSelectedRows; }
public static List<LayoutRow> getSelectedRows(Layout layout, List<String> selectedRowNames, boolean showAlwaysSelected) { LayoutRow[] rows = layout.getRows(); List<LayoutRow> selectedRows = new ArrayList<LayoutRow>(); if (rows != null) { for (LayoutRow row : rows) { if (row.isAlwaysSelected() && showAlwaysSelected) { selectedRows.add(row); } else if (selectedRowNames == null && row.isSelectedByDefault() && !row.isAlwaysSelected()) { selectedRows.add(row); } else if (selectedRowNames != null && selectedRowNames.contains(row.getName())) { selectedRows.add(row); } } } // preserve selected rows order Collections.sort(selectedRows, new LayoutRowsSorter(selectedRowNames)); return selectedRows; }