@Override public void preDelete(BE dataEntity, Transaction<BE> tx) { CanonicalPath dataPath = tx.extractCanonicalPath(dataEntity); BE rt = null; try { rt = tx.find(dataPath.up()); } catch (ElementNotFoundException e) { Fetcher.throwNotFoundException(context); } if (ReadWrite.isResourceTypeInMetadataPack(rt, tx)) { throw new IllegalArgumentException( "Data '" + dataPath.getSegment().getElementId() + "' cannot be deleted" + " under resource type " + dataPath.up() + ", because it is part of a meta data pack." + " Doing this would invalidate meta data pack's identity."); } }
@Override public void preDelete(BE dataEntity, Transaction<BE> tx) { CanonicalPath dataPath = tx.extractCanonicalPath(dataEntity); BE ot = null; try { ot = tx.find(dataPath.up()); } catch (ElementNotFoundException e) { Fetcher.throwNotFoundException(context); } if (ReadWrite.isResourceTypeInMetadataPack(ot, tx)) { throw new IllegalArgumentException( "Data '" + dataPath.getSegment().getElementId() + "' cannot be deleted" + " under operation type " + dataPath.up() + ", because the owning resource type is part of a meta data pack." + " Doing this would invalidate meta data pack's identity."); } }
public DataEntity(CanonicalPath path, StructuredData value, String identityHash, String contentHash, String syncHash, Map<String, Object> properties) { this(path.up(), DataRole.valueOf(path.getSegment().getElementId()), value, identityHash, contentHash, syncHash, properties); }
public DataEntity(CanonicalPath path, StructuredData value, Map<String, Object> properties) { this(path.up(), DataRole.valueOf(path.getSegment().getElementId()), value, properties); }
@Override public Single visitOperationType(Void parameter) { ResourceTypes.Single rt = inspect(path.up(), ResourceTypes.Single.class); return accessInterface.cast(rt.operationTypes().get(path.getSegment().getElementId())); }
@Override public Single visitData(Void parameter) { String rt = ids.getResourceTypeId(); String ot = ids.getOperationTypeId(); if (rt != null && ot == null) { ResourceTypes.Single rts = inspect(path.up(), ResourceTypes.Single.class); DataRole.ResourceType role = DataRole.ResourceType.valueOf(ids.getDataRole()); return accessInterface.cast(rts.data().get(role)); } else if (ot != null) { OperationTypes.Single ots = inspect(path.up(), OperationTypes.Single.class); DataRole.OperationType role = DataRole.OperationType.valueOf(ids.getDataRole()); return accessInterface.cast(ots.data().get(role)); } else { Resources.Single res = inspect(path.up(), Resources.Single.class); DataRole.Resource role = DataRole.Resource.valueOf(ids.getDataRole()); return accessInterface.cast(res.data().get(role)); } }
@Override public Single visitMetadataPack(Void parameter) { return accessInterface.cast(tenants().get(path.up().getSegment().getElementId()) .metadataPacks().get(path.getSegment().getElementId())); }
public static boolean canIncorporate(CanonicalPath entityPath) { SegmentType entityType = entityPath.getSegment().getElementType(); SegmentType parentType = entityPath.up().getSegment().getElementType(); return SegmentType.t.equals(parentType) && (SegmentType.rt.equals(entityType) || SegmentType.mt.equals(entityType)); }
public static boolean canIncorporate(CanonicalPath entityPath) { SegmentType entityType = entityPath.getSegment().getElementType(); SegmentType parentType = entityPath.up().getSegment().getElementType(); return SegmentType.t.equals(parentType) && (SegmentType.rt.equals(entityType) || SegmentType.mt.equals(entityType)); }
ctx.identity.append(child.accept(this, ctx).identityHash); }, new IntermediateHashContext(entityPath == null ? null : entityPath.up(), RelativePath.empty().get()));
@Override public void preUpdate(BE dataEntity, DataEntity.Update update, Transaction<BE> tx) { if (update.getValue() == null) { return; } BE mp = tx.traverseToSingle(dataEntity, Query.path().with( Related.asTargetBy(contains), //up to resource type Related.asTargetBy(incorporates), With.type(MetadataPack.class) // up to the pack ).get()); if (mp != null) { CanonicalPath dataPath = tx.extractCanonicalPath(dataEntity); throw new IllegalArgumentException( "Data '" + dataPath.getSegment().getElementId() + "' cannot be updated" + " under resource type " + dataPath.up() + ", because it is part of a meta data pack." + " Doing this would invalidate meta data pack's identity."); } }
@Override public void preUpdate(BE dataEntity, DataEntity.Update update, Transaction<BE> tx) { if (update.getValue() == null) { return; } BE mp = tx.traverseToSingle(dataEntity, Query.path().with( asTargetBy(contains), //up to operation type asTargetBy(contains), //up to resource type asTargetBy(incorporates), With.type(MetadataPack.class) // up to the pack ).get()); if (mp != null) { CanonicalPath dataPath = tx.extractCanonicalPath(dataEntity); throw new IllegalArgumentException( "Data '" + dataPath.getSegment().getElementId() + "' cannot be updated" + " under operation type " + dataPath.up() + ", because the owning resource type is part of a meta data pack." + " Doing this would invalidate meta data pack's identity."); } }
CanonicalPath childCp = tree.getPath().applyTo(root); @SuppressWarnings("unchecked") ResolvableToSingle<?, ?> parentAccess = inv.inspect(childCp.up(), ResolvableToSingle.class);
@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()); }); }
CanonicalPath cp = extractCanonicalPath(v); String identityHash = extractIdentityHash(v); e = new DataEntity(cp.up(), DataRole.valueOf(cp.getSegment().getElementId()), loadStructuredData(v, hasData), identityHash, extractContentHash(v), extractSyncHash(v)); break;