protected DataStoreTransaction getTransaction(Class<?> cls) { DataStoreTransaction transaction = transactions.get(this.multiplexManager.getSubManager(cls)); if (transaction == null) { Class entityClass = multiplexManager.getDictionary().lookupEntityClass(cls); throw new InvalidCollectionException(entityClass == null ? cls.getName() : entityClass.getName()); } return transaction; }
@Override public void handle(StateContext state, RootCollectionLoadEntitiesContext ctx) { String entityName = ctx.term().getText(); EntityDictionary dictionary = state.getRequestScope().getDictionary(); Class<?> entityClass = dictionary.getEntityClass(entityName); if (entityClass == null || !dictionary.isRoot(entityClass)) { throw new InvalidCollectionException(entityName); } state.setState(new CollectionTerminalState(entityClass, Optional.empty(), Optional.empty())); }
@Override public void handle(StateContext state, RootCollectionLoadEntitiesContext ctx) { String entityName = ctx.term().getText(); EntityDictionary dictionary = state.getRequestScope().getDictionary(); Class<?> entityClass = dictionary.getEntityClass(entityName); if (entityClass == null || !dictionary.isRoot(entityClass)) { throw new InvalidCollectionException(entityName); } state.setState(new CollectionTerminalState(entityClass, Optional.empty(), Optional.empty())); }
@Override public void handle(StateContext state, RootCollectionRelationshipContext ctx) { PersistentResource record = entityRecord(state, ctx.entity()); String relationName = ctx.relationship().term().getText(); try { Optional<FilterExpression> filterExpression = state.getRequestScope().getExpressionForRelation(record, relationName); record.getRelationCheckedFiltered(relationName, filterExpression, Optional.empty(), Optional.empty()); } catch (InvalidAttributeException e) { throw new InvalidCollectionException(relationName); } state.setState(new RelationshipTerminalState(record, relationName)); }
@Override public void handle(StateContext state, RootCollectionRelationshipContext ctx) { PersistentResource record = entityRecord(state, ctx.entity()); String relationName = ctx.relationship().term().getText(); try { Optional<FilterExpression> filterExpression = state.getRequestScope().getExpressionForRelation(record, relationName); record.getRelationCheckedFiltered(relationName, filterExpression, Optional.empty(), Optional.empty()); } catch (InvalidAttributeException e) { throw new InvalidCollectionException(relationName); } state.setState(new RelationshipTerminalState(record, relationName)); }
@Override public void handle(StateContext state, SubCollectionRelationshipContext ctx) { String id = ctx.entity().id().getText(); String subCollection = ctx.entity().term().getText(); PersistentResource childRecord; try { childRecord = resource.getRelation(subCollection, id); } catch (InvalidAttributeException e) { throw new InvalidCollectionException(subCollection); } String relationName = ctx.relationship().term().getText(); try { Optional<FilterExpression> filterExpression = state.getRequestScope().getExpressionForRelation(resource, subCollection); childRecord.getRelationCheckedFiltered(relationName, filterExpression, Optional.empty(), Optional.empty()); } catch (InvalidAttributeException e) { throw new InvalidCollectionException(relationName); } state.setState(new RelationshipTerminalState(childRecord, relationName)); } }
@Override public void handle(StateContext state, SubCollectionRelationshipContext ctx) { String id = ctx.entity().id().getText(); String subCollection = ctx.entity().term().getText(); PersistentResource childRecord; try { childRecord = resource.getRelation(subCollection, id); } catch (InvalidAttributeException e) { throw new InvalidCollectionException(subCollection); } String relationName = ctx.relationship().term().getText(); try { Optional<FilterExpression> filterExpression = state.getRequestScope().getExpressionForRelation(resource, subCollection); childRecord.getRelationCheckedFiltered(relationName, filterExpression, Optional.empty(), Optional.empty()); } catch (InvalidAttributeException e) { throw new InvalidCollectionException(relationName); } state.setState(new RelationshipTerminalState(childRecord, relationName)); } }
@Override public void handle(StateContext state, SubCollectionReadEntityContext ctx) { String id = ctx.entity().id().getText(); String subCollection = ctx.entity().term().getText(); try { PersistentResource nextRecord = resource.getRelation(subCollection, id); state.setState(new RecordTerminalState(nextRecord)); } catch (InvalidAttributeException e) { throw new InvalidCollectionException(subCollection); } }
@Override public void handle(StateContext state, SubCollectionSubCollectionContext ctx) { String id = ctx.entity().id().getText(); String subCollection = ctx.entity().term().getText(); try { state.setState(new RecordState(resource.getRelation(subCollection, id))); } catch (InvalidAttributeException e) { throw new InvalidCollectionException(subCollection); } }
RelationshipType type = dictionary.getRelationshipType(resource.getObject(), subCollection); if (type == RelationshipType.NONE) { throw new InvalidCollectionException(subCollection); throw new InvalidCollectionException(subCollection);
RelationshipType type = dictionary.getRelationshipType(resource.getObject(), subCollection); if (type == RelationshipType.NONE) { throw new InvalidCollectionException(subCollection); throw new InvalidCollectionException(subCollection);
@Override public void handle(StateContext state, SubCollectionSubCollectionContext ctx) { String id = ctx.entity().id().getText(); String subCollection = ctx.entity().term().getText(); try { state.setState(new RecordState(resource.getRelation(subCollection, id))); } catch (InvalidAttributeException e) { throw new InvalidCollectionException(subCollection); } }
@Override public void handle(StateContext state, SubCollectionReadEntityContext ctx) { String id = ctx.entity().id().getText(); String subCollection = ctx.entity().term().getText(); try { PersistentResource nextRecord = resource.getRelation(subCollection, id); state.setState(new RecordTerminalState(nextRecord)); } catch (InvalidAttributeException e) { throw new InvalidCollectionException(subCollection); } }
private PersistentResource<?> entityRecord(StateContext state, EntityContext entity) { String entityName = entity.term().getText(); String id = entity.id().getText(); EntityDictionary dictionary = state.getRequestScope().getDictionary(); Class<?> entityClass = dictionary.getEntityClass(entityName); if (entityClass == null || !dictionary.isRoot(entityClass)) { throw new InvalidCollectionException(entityName); } return PersistentResource.loadRecord(entityClass, id, state.getRequestScope()); } }
private PersistentResource<?> entityRecord(StateContext state, EntityContext entity) { String entityName = entity.term().getText(); String id = entity.id().getText(); EntityDictionary dictionary = state.getRequestScope().getDictionary(); Class<?> entityClass = dictionary.getEntityClass(entityName); if (entityClass == null || !dictionary.isRoot(entityClass)) { throw new InvalidCollectionException(entityName); } return PersistentResource.loadRecord(entityClass, id, state.getRequestScope()); } }