public static String of(Iterable<? extends Entity<? extends Entity.Blueprint, ?>> entities, Inventory inventory) { return of(entities.iterator(), inventory); }
public static String of(Entity<? extends Entity.Blueprint, ?> entity, Inventory inventory) { return of(InventoryStructure.of(entity, inventory)); }
public static String of(MetadataPack mp, Inventory inventory) { List<Entity<? extends Entity.Blueprint, ?>> all = new ArrayList<>(); all.addAll(inventory.inspect(mp).resourceTypes().getAll().entities()); all.addAll(inventory.inspect(mp).metricTypes().getAll().entities()); return of(all, inventory); }
@SuppressWarnings("unchecked") @Override protected String getProposedId(Transaction<BE> tx, MetadataPack.Blueprint blueprint) { Iterator<? extends Entity<? extends Entity.Blueprint, ?>> members = blueprint.getMembers().stream() .map((p) -> { SegmentType type = p.getSegment().getElementType(); Class<?> cls = Entity.entityTypeFromSegmentType(type); try { BE e = tx.find(p); return (Entity<? extends Entity.Blueprint, ?>) tx.convert(e, cls); } catch (ElementNotFoundException ex) { throw new EntityNotFoundException(cls, Query.filters(Query.to(p))); } }).iterator(); return IdentityHash.of(members, context.inventory.keepTransaction(tx)); }
@Override public Updater<Update, DataEntity> update() { return new Updater<>((u) -> { StructuredData newValue = valueOrDefault(u.getValue(), getValue()); String identityHash = getIdentityHash(); if (u.getValue() != null) { DataEntity.Blueprint updateBlueprint = DataEntity.Blueprint.builder().withRole(getRole()) .withValue(u.getValue()).build(); InventoryStructure<DataEntity.Blueprint> structure = InventoryStructure.of(updateBlueprint).build(); identityHash = IdentityHash.of(structure); } return new DataEntity(this.getPath().up(), this.getRole(), newValue, identityHash, getContentHash(), getSyncHash(), u.getProperties()); }); }