use of org.apache.commons.lang3.builder.CompareToBuilder in project CzechIdMng by bcvsolutions.
the class DefaultIdmFormDefinitionService method compareCompatibleChanges.
/**
* Compare attributes, which can be update
*
* @param savedAttribute
* @param attribute
* @return
*/
private int compareCompatibleChanges(IdmFormAttributeDto savedAttribute, IdmFormAttributeDto attribute) {
CompareToBuilder builder = new CompareToBuilder();
//
if (attribute.getSeq() != null) {
builder.append(savedAttribute.getSeq(), attribute.getSeq());
}
builder.append(savedAttribute.getName(), attribute.getName());
builder.append(savedAttribute.getFaceType(), attribute.getFaceType());
builder.append(savedAttribute.isReadonly(), attribute.isReadonly());
builder.append(savedAttribute.isRequired(), attribute.isRequired());
builder.append(savedAttribute.getDefaultValue(), attribute.getDefaultValue());
builder.append(savedAttribute.getDescription(), attribute.getDescription());
builder.append(savedAttribute.isMultiple(), attribute.isMultiple());
builder.append(savedAttribute.getPlaceholder(), attribute.getPlaceholder());
builder.append(savedAttribute.isUnmodifiable(), attribute.isUnmodifiable());
//
return builder.toComparison();
}
use of org.apache.commons.lang3.builder.CompareToBuilder in project lavagna by digitalfondue.
the class ExcelExportService method getWorkbookFromSearchFilters.
private HSSFWorkbook getWorkbookFromSearchFilters(int projectId, String sheetName, List<SearchFilter> filters, UserWithPermission user) {
List<CardLabel> labels = cardLabelRepository.findLabelsByProject(projectId);
CollectionUtils.filter(labels, new Predicate<CardLabel>() {
@Override
public boolean evaluate(CardLabel cl) {
if (cl.getDomain().equals(CardLabel.LabelDomain.SYSTEM)) {
if (cl.getName().equals(SYSTEM_LABEL_ASSIGNED) || cl.getName().equals(SYSTEM_LABEL_DUE_DATE) || cl.getName().equals(SYSTEM_LABEL_MILESTONE)) {
return true;
}
return false;
}
return true;
}
});
Collections.sort(labels, new Comparator<CardLabel>() {
public int compare(CardLabel l1, CardLabel l2) {
return new CompareToBuilder().append(l1.getDomain(), l2.getDomain()).append(l1.getName(), l2.getName()).toComparison();
}
});
SearchResults cards = searchService.find(filters, projectId, null, user);
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet(sheetName);
Row header = sheet.createRow(0);
int headerColPos = 0;
header.createCell(headerColPos++).setCellValue("Board");
header.createCell(headerColPos++).setCellValue("ID");
header.createCell(headerColPos++).setCellValue("Name");
header.createCell(headerColPos++).setCellValue("Column");
header.createCell(headerColPos++).setCellValue("Status");
header.createCell(headerColPos++).setCellValue("Description");
header.createCell(headerColPos++).setCellValue("Created");
header.createCell(headerColPos++).setCellValue("Created by");
for (CardLabel cl : labels) {
header.createCell(headerColPos++).setCellValue(WordUtils.capitalizeFully(cl.getName().replace("_", " ")));
}
Map<Integer, BoardColumnInfo> colCache = new HashMap<>();
Map<Integer, String> userCache = new HashMap<>();
Map<Integer, String> cardCache = new HashMap<>();
Map<Integer, String> listValueCache = new HashMap<>();
int rowPos = 1;
for (CardFullWithCounts card : cards.getFound()) {
int colPos = 0;
Row row = sheet.createRow(rowPos++);
// Board
row.createCell(colPos++).setCellValue(card.getBoardShortName());
// ID
row.createCell(colPos++).setCellValue(card.getSequence());
// Name
row.createCell(colPos++).setCellValue(card.getName());
// Column
if (!colCache.containsKey(card.getColumnId())) {
colCache.put(card.getColumnId(), boardColumnRepository.getColumnInfoById(card.getColumnId()));
}
BoardColumnInfo col = colCache.get(card.getColumnId());
row.createCell(colPos++).setCellValue(col.getColumnName());
// ColumnDefinition - status
row.createCell(colPos++).setCellValue(card.getColumnDefinition().toString());
// Description
CardDataHistory desc = cardDataService.findLatestDescriptionByCardId(card.getId());
row.createCell(colPos++).setCellValue(desc != null ? desc.getContent() : "");
// Creation date
row.createCell(colPos++).setCellValue(new SimpleDateFormat("yyyy.MM.dd").format(card.getCreationDate()));
// Created by
row.createCell(colPos++).setCellValue(getUserDescription(userCache, card.getCreationUser()));
// Labels
fillLabelValues(row, colPos, labels, cardLabelRepository.findCardLabelValuesByCardId(card.getId()), userCache, cardCache, listValueCache);
}
sheet.setAutoFilter(new CellRangeAddress(0, 0, 0, headerColPos - 1));
// Auto size the columns except for the description
for (int i = 0; i < headerColPos; i++) {
if (!header.getCell(i).getStringCellValue().equals("Description")) {
sheet.autoSizeColumn(i);
} else {
sheet.setColumnWidth(i, 30 * 256);
}
}
return wb;
}
use of org.apache.commons.lang3.builder.CompareToBuilder in project lavagna by digitalfondue.
the class CardService method fetchAllInColumn.
public List<CardFullWithCounts> fetchAllInColumn(int columnId) {
List<CardFull> cards = cardRepository.findAllByColumnId(columnId);
if (cards.isEmpty()) {
return Collections.emptyList();
}
List<CardFullWithCounts> res = fetchCardFull(cards);
Collections.sort(res, new Comparator<CardFullWithCounts>() {
@Override
public int compare(CardFullWithCounts o1, CardFullWithCounts o2) {
return new CompareToBuilder().append(o1.getOrder(), o2.getOrder()).toComparison();
}
});
//
return res;
}
use of org.apache.commons.lang3.builder.CompareToBuilder in project BroadleafCommerce by BroadleafCommerce.
the class FieldGroup method getGroupItems.
public Set<FieldGroupItem> getGroupItems() {
List<FieldGroupItem> myGroupItems = new ArrayList<>(groupItems);
Collections.sort(myGroupItems, new Comparator<FieldGroupItem>() {
@Override
public int compare(FieldGroupItem o1, FieldGroupItem o2) {
return new CompareToBuilder().append(o1.getOrder(), o2.getOrder()).append(o1.getFriendlyName(), o2.getFriendlyName()).append(o1.getName(), o2.getName()).toComparison();
}
});
if (!alternateOrderedGroupItems.isEmpty()) {
List<FieldGroupItem> mapGroupItemsList = new ArrayList<>(alternateOrderedGroupItems);
Collections.sort(mapGroupItemsList, new Comparator<FieldGroupItem>() {
@Override
public int compare(FieldGroupItem o1, FieldGroupItem o2) {
return new CompareToBuilder().append(o1.getOrder(), o2.getOrder()).append(o1.getFriendlyName(), o2.getFriendlyName()).append(o1.getName(), o2.getName()).toComparison();
}
});
/*
alternate ordered fields whose order is less or equal to zero appear first and are
prepended to the response list in order
*/
List<FieldGroupItem> smallOrderGroupItems = new ArrayList<>();
for (FieldGroupItem mapField : mapGroupItemsList) {
if (mapField.getOrder() <= 0) {
smallOrderGroupItems.add(mapField);
}
}
myGroupItems.addAll(0, smallOrderGroupItems);
/*
Alternate ordered fields (specifically custom fields) have a different ordering rule than regular fields. For example,
if a user enters 3 for the field order value for a custom field, that custom field should be the third
on the form. Regular BLC AdminPresentation fields tends to have orders like 1000, 2000, etc..., so this
distinction is necessary.
*/
for (FieldGroupItem mapField : mapGroupItemsList) {
if (mapField.getOrder() <= 0) {
continue;
}
if (mapField.getOrder() < myGroupItems.size() + 1) {
myGroupItems.add(mapField.getOrder() - 1, mapField);
continue;
}
myGroupItems.add(mapField);
}
}
// don't allow any modification of the fields
return Collections.unmodifiableSet(new LinkedHashSet<>(myGroupItems));
}
use of org.apache.commons.lang3.builder.CompareToBuilder in project bitflyer4j by after-the-sunrise.
the class Entity method compareTo.
@Override
public int compareTo(Entity o) {
CompareToBuilder b = new CompareToBuilder();
b.append(_t, o._t);
b.append(_c, o._c);
return b.toComparison();
}
Aggregations