use of io.lumeer.api.model.CollectionPurposeType in project engine by Lumeer.
the class CollectionCreator method getCollection.
private Collection getCollection(final JSONObject o) {
final Collection c = new Collection((String) o.get(Collection.CODE), (String) o.get(Collection.NAME), (String) o.get(Collection.ICON), (String) o.get(Collection.COLOR), null);
c.setDataDescription((String) o.get(Collection.DATA_DESCRIPTION));
final JSONObject purpose = (JSONObject) o.get(Collection.PURPOSE);
if (purpose != null) {
var purposeType = Utils.computeIfNotNull((String) purpose.get(CollectionPurpose.TYPE), CollectionPurposeType::valueOf);
final JSONObject metaData = (JSONObject) purpose.get(CollectionPurpose.META_DATA);
final DataDocument dataDocument = new DataDocument();
if (metaData != null) {
metaData.forEach((k, v) -> dataDocument.append(templateParser.translateConfig(k, constraintManager).toString(), templateParser.translateConfig(v, constraintManager)));
}
c.setPurpose(new CollectionPurpose(purposeType, dataDocument));
}
c.setPriority((Long) o.get(Collection.PRIORITY));
return c;
}
use of io.lumeer.api.model.CollectionPurposeType in project engine by Lumeer.
the class CollectionPurposeCodec method convertFromDocument.
public static CollectionPurpose convertFromDocument(Document bson) {
if (bson == null) {
return new CollectionPurpose(CollectionPurposeType.None, new DataDocument());
}
String typeString = bson.getString(TYPE);
CollectionPurposeType purposeType = typeString != null ? CollectionPurposeType.valueOf(typeString) : CollectionPurposeType.None;
Document metaData = bson.get(META_DATA, Document.class);
return new CollectionPurpose(purposeType, new DataDocument(metaData == null ? new Document() : metaData));
}
Aggregations