use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType in project midpoint by Evolveum.
the class RLookupTableRow method toJAXB.
public LookupTableRowType toJAXB() {
LookupTableRowType row = new LookupTableRowType();
row.setId(Long.valueOf(id));
row.setKey(key);
row.setLastChangeTimestamp(lastChangeTimestamp);
row.setValue(value);
row.setLabel(RPolyString.copyToJAXB(label));
return row;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType in project midpoint by Evolveum.
the class LookupTableHelper method addLookupTableRows.
private void addLookupTableRows(Session session, String tableOid, Collection<PrismContainerValue> values, int currentId, boolean deleteBeforeAdd) throws SchemaException {
for (PrismContainerValue value : values) {
LookupTableRowType rowType = new LookupTableRowType();
rowType.setupContainerValue(value);
if (deleteBeforeAdd) {
deleteRowByKey(session, tableOid, rowType.getKey());
}
RLookupTableRow row = RLookupTableRow.toRepo(tableOid, rowType);
row.setId(currentId);
currentId++;
session.save(row);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType in project midpoint by Evolveum.
the class LookupTableHelper method updateLoadedLookupTable.
public <T extends ObjectType> void updateLoadedLookupTable(PrismObject<T> object, Collection<SelectorOptions<GetOperationOptions>> options, Session session) throws SchemaException {
if (!SelectorOptions.hasToLoadPath(LookupTableType.F_ROW, options)) {
return;
}
LOGGER.debug("Loading lookup table data.");
GetOperationOptions getOption = findLookupTableGetOption(options);
RelationalValueSearchQuery queryDef = getOption == null ? null : getOption.getRelationalValueSearchQuery();
Criteria criteria = setupLookupTableRowsQuery(session, queryDef, object.getOid());
if (queryDef != null && queryDef.getPaging() != null) {
ObjectPaging paging = queryDef.getPaging();
if (paging.getOffset() != null) {
criteria.setFirstResult(paging.getOffset());
}
if (paging.getMaxSize() != null) {
criteria.setMaxResults(paging.getMaxSize());
}
ItemPath orderByPath = paging.getOrderBy();
if (paging.getDirection() != null && orderByPath != null && !orderByPath.isEmpty()) {
if (orderByPath.size() > 1 || !(orderByPath.first() instanceof NameItemPathSegment) && !(orderByPath.first() instanceof IdentifierPathSegment)) {
throw new SchemaException("OrderBy has to consist of just one naming or identifier segment");
}
ItemPathSegment first = orderByPath.first();
String orderBy = first instanceof NameItemPathSegment ? ((NameItemPathSegment) first).getName().getLocalPart() : RLookupTableRow.ID_COLUMN_NAME;
switch(paging.getDirection()) {
case ASCENDING:
criteria.addOrder(Order.asc(orderBy));
break;
case DESCENDING:
criteria.addOrder(Order.desc(orderBy));
break;
}
}
}
List<RLookupTableRow> rows = criteria.list();
if (rows == null || rows.isEmpty()) {
return;
}
LookupTableType lookup = (LookupTableType) object.asObjectable();
List<LookupTableRowType> jaxbRows = lookup.getRow();
for (RLookupTableRow row : rows) {
LookupTableRowType jaxbRow = row.toJAXB();
jaxbRows.add(jaxbRow);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType in project midpoint by Evolveum.
the class LookupTableTest method test260ReplaceRowsExistingId.
@Test
public void test260ReplaceRowsExistingId() throws Exception {
OperationResult result = new OperationResult("test260ReplaceRowsExistingId");
LookupTableRowType row5 = new LookupTableRowType(prismContext);
// dangerous
row5.setId(5L);
row5.setKey("key 5 plus");
row5.setValue("value 5 plus");
row5.setLastChangeTimestamp(XmlTypeConverter.createXMLGregorianCalendar(new Date(99, 3, 10)));
List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(LookupTableType.class, prismContext).item(F_ROW).replace(row5).asItemDeltas();
executeAndCheckModification(modifications, result, 0, null);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType in project midpoint by Evolveum.
the class LookupTableTest method test228AddKeylessRow2.
@Test(expectedExceptions = SchemaException.class)
public void test228AddKeylessRow2() throws Exception {
OperationResult result = new OperationResult("test228AddKeylessRow2");
LookupTableRowType row = new LookupTableRowType();
row.setValue("value");
List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(LookupTableType.class, prismContext).item(F_ROW).add(row).asItemDeltas();
repositoryService.modifyObject(LookupTableType.class, tableOid, modifications, null, result);
}
Aggregations