@Override public Single visitTenant(Void parameter) { return accessInterface.cast(tenants().get(ids.getTenantId())); }
public static <BE> void validate(Transaction<BE> tx, StructuredData data, BE dataEntity) { CanonicalPath path = tx.extractCanonicalPath(dataEntity); DataRole role = DataRole.valueOf(path.ids().getDataRole()); if (role.isSchema()) { try { JsonNode schema = new JsonNodeReader(new ObjectMapper()) .fromInputStream(BaseData.class.getResourceAsStream("/json-meta-schema.json")); CanonicalPath dataPath = tx.extractCanonicalPath(dataEntity); validate(dataPath, convert(data), schema); } catch (IOException e) { throw new IllegalStateException("Could not load the embedded JSON Schema meta-schema."); } } else { validateIfSchemaFound(tx, data, dataEntity, Query.path().with(navigateToSchema(role)).get()); } }
@Override public Single visitEnvironment(Void parameter) { return accessInterface.cast(tenants().get(ids.getTenantId()).environments() .get(ids.getEnvironmentId())); }
String tenantId = cp.ids().getTenantId();
CanonicalPath resourceTypePath = null; try { CanonicalPath tenant = CanonicalPath.of().tenant(parentPath.ids().getTenantId()).get(); resourceTypePath = Util.canonicalize(blueprint.getResourceTypePath(), tenant, parentPath, ResourceType.SEGMENT_TYPE);
CanonicalPath tenant = CanonicalPath.of().tenant(parentPath.ids().getTenantId()).get(); CanonicalPath metricTypePath = Util.canonicalize(blueprint.getMetricTypePath(), tenant, parentPath, MetricType.SEGMENT_TYPE);
@Override public Single visitMetric(Void parameter) { Tenants.Single tenant = tenants().get(ids.getTenantId()); RelativePath resourcePath = ids.getResourcePath(); String feedId = ids.getFeedId(); String environmentId = ids.getEnvironmentId(); String metricId = ids.getMetricId(); ResolvableToSingle<?, ?> iface; if (resourcePath == null) { if (feedId == null) { iface = tenant.environments().get(environmentId).metrics().get(metricId); } else { iface = tenant.feeds().get(feedId).metrics().get(metricId); } } else { if (feedId == null) { iface = tenant.environments().get(environmentId).resources() .descendContained(ids.getResourcePath()).metrics().get(metricId); } else { iface = tenant.feeds().get(feedId).resources().descendContained(ids.getResourcePath()) .metrics().get(metricId); } } return accessInterface.cast(iface); }
@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 visitRelationship(Void parameter) { return accessInterface.cast(relationships().get(ids.getRelationshipId())); }
@Override public Single visitFeed(Void parameter) { return accessInterface.cast(tenants().get(ids.getTenantId()).feeds() .get(ids.getFeedId())); }
@Override public Single visitResourceType(Void parameter) { Tenants.Single ten = tenants().get(ids.getTenantId()); return accessInterface.cast(ids.getFeedId() == null ? ten.resourceTypes().get(ids.getResourceTypeId()) : ten.feeds().get(ids.getFeedId()).resourceTypes() .get(ids.getResourceTypeId())); }
@Override public MetadataPacks.Single create(MetadataPack.Blueprint blueprint, boolean cache) throws EntityAlreadyExistsException { blueprint.getMembers().forEach(p -> { if (p.ids().getFeedId() != null) { throw new IllegalArgumentException("Only global types can be part of a metadata pack. No " + "feed-local types are allowed but '" + p + "' encountered."); } }); return new Single<>(context.toCreatedEntity(doCreate(blueprint), cache)); } }
@Override public Single visitMetricType(Void parameter) { Tenants.Single ten = tenants().get(ids.getTenantId()); return accessInterface.cast(ids.getFeedId() == null ? ten.metricTypes().get(ids.getMetricTypeId()) : ten.feeds().get(ids.getFeedId()).metricTypes() .get(ids.getMetricTypeId())); }
@Override public Single visitResource(Void parameter) { Tenants.Single tenant = tenants().get(ids.getTenantId()); Resources.Single access; if (ids.getFeedId() == null) { access = tenant.environments().get(ids.getEnvironmentId()).resources() .descendContained(ids.getResourcePath()); } else { access = tenant.feeds().get(ids.getFeedId()).resources().descendContained(ids.getResourcePath()); } return accessInterface.cast(access); }