@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)); } }
private static Filter[] navigateToSchema(DataRole role) { if (role == DataRole.Resource.configuration) { return new Filter[]{ //up to the containing resource Related.asTargetBy(contains), //up to the defining resource type Related.asTargetBy(defines), //down to the contained data entity Related.by(contains), With.type(DataEntity.class), //with id of configuration schema With.id(DataRole.ResourceType.configurationSchema.name()) }; } else if (role == DataRole.Resource.connectionConfiguration) { return new Filter[]{ //up to the containing resource Related.asTargetBy(contains), //up to the defining resource type Related.asTargetBy(defines), //down to the contained data entity Related.by(contains), With.type(DataEntity.class), //with id of configuration schema With.id(DataRole.ResourceType.connectionConfigurationSchema.name()) }; } else { throw new IllegalStateException("Incomplete mapping of navigation to data schema. Role '" + role + "'" + " is not handled."); } }