use of org.apache.syncope.common.lib.Attr in project syncope by apache.
the class LinkedAccountPlainAttrsPanel method setAttrs.
@Override
protected void setAttrs() {
List<Attr> attrs = new ArrayList<>();
List<PlainSchemaTO> notReadonlyValues = schemas.values().stream().filter(schema -> checkIsReadonlyAttr(schema.getKey())).collect(Collectors.toList());
setFixedAttr(notReadonlyValues);
Map<String, Attr> attrMap = EntityTOUtils.buildAttrMap(fixedAttrs);
attrs.addAll(notReadonlyValues.stream().map(schema -> {
Attr attrTO = new Attr();
attrTO.setSchema(schema.getKey());
if (attrMap.get(schema.getKey()) == null || attrMap.get(schema.getKey()).getValues().isEmpty()) {
attrTO.getValues().add("");
} else {
attrTO = attrMap.get(schema.getKey());
}
return attrTO;
}).collect(Collectors.toList()));
fixedAttrs.clear();
fixedAttrs.addAll(attrs);
}
use of org.apache.syncope.common.lib.Attr in project syncope by apache.
the class AnyWizardBuilder method fixPlainAndVirAttrs.
@Override
protected void fixPlainAndVirAttrs(final AnyTO updated, final AnyTO original) {
// form layout, which might have not included some plain or virtual attributes
for (Attr plainAttr : original.getPlainAttrs()) {
if (updated.getPlainAttr(plainAttr.getSchema()).isEmpty()) {
updated.getPlainAttrs().add(plainAttr);
}
}
for (Attr virAttr : original.getVirAttrs()) {
if (updated.getVirAttr(virAttr.getSchema()).isEmpty()) {
updated.getVirAttrs().add(virAttr);
}
}
if (updated instanceof GroupableRelatableTO && original instanceof GroupableRelatableTO) {
GroupableRelatableTO.class.cast(original).getMemberships().forEach(oMemb -> GroupableRelatableTO.class.cast(updated).getMembership(oMemb.getGroupKey()).ifPresent(uMemb -> {
oMemb.getPlainAttrs().stream().filter(attr -> uMemb.getPlainAttr(attr.getSchema()).isEmpty()).forEach(attr -> uMemb.getPlainAttrs().add(attr));
oMemb.getVirAttrs().stream().filter(attr -> uMemb.getVirAttr(attr.getSchema()).isEmpty()).forEach(attr -> uMemb.getVirAttrs().add(attr));
}));
}
// remove from the updated object any plain or virtual attribute without values, thus triggering for removal in
// the generated patch
updated.getPlainAttrs().removeIf(attr -> attr.getValues().isEmpty());
updated.getVirAttrs().removeIf(attr -> attr.getValues().isEmpty());
if (updated instanceof GroupableRelatableTO) {
GroupableRelatableTO.class.cast(updated).getMemberships().forEach(memb -> {
memb.getPlainAttrs().removeIf(attr -> attr.getValues().isEmpty());
memb.getVirAttrs().removeIf(attr -> attr.getValues().isEmpty());
});
}
}
use of org.apache.syncope.common.lib.Attr in project syncope by apache.
the class PlainAttrs method setAttrs.
@Override
protected void setAttrs() {
Map<String, Attr> attrMap = EntityTOUtils.buildAttrMap(anyTO.getPlainAttrs());
List<Attr> attrs = schemas.values().stream().map(schema -> {
Attr attr = new Attr();
attr.setSchema(schema.getKey());
if (attrMap.get(schema.getKey()) == null || attrMap.get(schema.getKey()).getValues().isEmpty()) {
attr.getValues().add("");
} else {
attr = attrMap.get(schema.getKey());
}
return attr;
}).collect(Collectors.toList());
anyTO.getPlainAttrs().clear();
anyTO.getPlainAttrs().addAll(attrs);
}
use of org.apache.syncope.common.lib.Attr in project syncope by apache.
the class PlainAttrs method setAttrs.
@Override
protected void setAttrs(final MembershipTO membershipTO) {
Map<String, Attr> attrMap = GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).isPresent() ? EntityTOUtils.buildAttrMap(GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).get().getPlainAttrs()) : new HashMap<>();
List<Attr> attrs = membershipSchemas.get(membershipTO.getGroupKey()).values().stream().map(schema -> {
Attr attr = new Attr();
attr.setSchema(schema.getKey());
if (attrMap.get(schema.getKey()) == null || attrMap.get(schema.getKey()).getValues().isEmpty()) {
attr.getValues().add(StringUtils.EMPTY);
} else {
attr.getValues().addAll(attrMap.get(schema.getKey()).getValues());
}
return attr;
}).collect(Collectors.toList());
membershipTO.getPlainAttrs().clear();
membershipTO.getPlainAttrs().addAll(attrs);
}
use of org.apache.syncope.common.lib.Attr in project syncope by apache.
the class DerAttrs method setAttrs.
@Override
protected void setAttrs(final MembershipTO membershipTO) {
List<Attr> attrs = new ArrayList<>();
final Map<String, Attr> attrMap;
if (GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).isPresent()) {
attrMap = EntityTOUtils.buildAttrMap(GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).get().getDerAttrs());
} else {
attrMap = new HashMap<>();
}
membershipSchemas.get(membershipTO.getGroupKey()).values().forEach(schema -> {
Attr attrTO = new Attr();
attrTO.setSchema(schema.getKey());
if (attrMap.containsKey(schema.getKey())) {
attrTO.getValues().addAll(attrMap.get(schema.getKey()).getValues());
}
attrs.add(attrTO);
});
membershipTO.getDerAttrs().clear();
membershipTO.getDerAttrs().addAll(attrs);
}
Aggregations