/** * Parse an Entity reference string to an EntityReference. * * @param identityString the EntityReference reference * @return the EntityReference represented by the given reference */ public static EntityReference parseEntityReference(String identityString) { Objects.requireNonNull( identityString, "identityString must not be null" ); return new EntityReference( StringIdentity.identityOf( identityString ) ); }
/** * Parse an Entity reference string to an EntityReference. * * @param identityString the EntityReference reference * @return the EntityReference represented by the given reference */ public static EntityReference parseEntityReference(String identityString) { Objects.requireNonNull( identityString, "identityString must not be null" ); return new EntityReference( StringIdentity.identityOf( identityString ) ); }
private List<BalanceData> getCreditors() { // Creditor retrieval could be a use case in itself... List<BalanceData> creditors = new ArrayList<>(); creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.identityOf( "BakerAccount" ) ) ); creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.identityOf( "ButcherAccount" ) ) ); return creditors; }
private List<BalanceData> getCreditors() { // Creditor retrieval could be a use case in itself... List<BalanceData> creditors = new ArrayList<BalanceData>(); creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.identityOf( "BakerAccount" ) ) ); creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.identityOf( "ButcherAccount" ) ) ); return creditors; }
@Override protected void doInit() throws ResourceException { // /entity/{reference} Map<String, Object> attributes = getRequest().getAttributes(); identity = StringIdentity.identityOf( (String) attributes.get( "reference" ) ); }
@Override public void resource( String segment ) throws ResourceException { select( Forum.class, StringIdentity.identityOf( segment ) ); subResource( ForumResource.class ); } }
@Override public Person findPersonByName( String name ) { UnitOfWork uow = uowf.currentUnitOfWork(); return uow.get( Person.class, identityOf( "person-" + name ) ); }
@Override public void resource( String segment ) throws ResourceException { selectFromManyAssociation( ObjectSelection.current().get( Forum.class ).boards(), StringIdentity.identityOf( segment ) ); subResource( BoardResource.class ); } }
@Override public void resource( String segment ) throws ResourceException { selectFromManyAssociation( ObjectSelection.current().get( Forum.class ).boards(), StringIdentity.identityOf( segment ) ); subResource( BoardResource.class ); } }
@Override public Country createCountry( String countryCode, String countryName ) { UnitOfWork uow = uowf.currentUnitOfWork(); EntityBuilder<Country> builder = uow.newEntityBuilder( Country.class, identityOf( "country-" + countryCode ) ); builder.instance().name().set( countryName ); return builder.newInstance(); }
/** * @return a Some ValueComposite whose state is populated with test data. */ protected static Some buildSomeValue( Module module, UnitOfWork uow, String identity ) { ValueBuilder<Some> builder = module.newValueBuilder( Some.class ); Some proto = builder.prototype(); proto.identity().set( StringIdentity.identityOf( identity ) ); setSomeValueState( module, uow, proto ); return builder.newInstance(); }
@Override public Country createCountry( String countryCode, String countryName ) { UnitOfWork uow = uowf.currentUnitOfWork(); EntityBuilder<Country> builder = uow.newEntityBuilder( Country.class, identityOf( "country-" + countryCode ) ); builder.instance().name().set( countryName ); return builder.newInstance(); }
protected static Some buildSomeEntity( Module module, UnitOfWork uow, String identity ) { EntityBuilder<Some> builder = uow.newEntityBuilder( Some.class ); Some proto = builder.instance(); proto.identity().set( StringIdentity.identityOf( identity ) ); setSomeValueState( module, uow, proto ); return builder.newInstance(); }
/** * @return a Some ValueComposite whose state is populated with test data. */ protected static Some buildSomeValue( Module module, UnitOfWork uow, String identity ) { ValueBuilder<Some> builder = module.newValueBuilder( Some.class ); Some proto = builder.prototype(); proto.identity().set( StringIdentity.identityOf( identity ) ); setSomeValueState( module, uow, proto ); return builder.newInstance(); }
@Test public void script33() { QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Domain gaming = unitOfWork.get( Domain.class, StringIdentity.identityOf( "Gaming" ) ); Query<Person> query = unitOfWork.newQuery( qb.where( contains( person.interests(), gaming ) ) ); System.out.println( "*** script33: " + query ); verifyUnorderedResults( query, "Joe Doe" ); }
@Test public void script34() { QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Female annDoe = unitOfWork.get( Female.class, StringIdentity.identityOf( "anndoe" ) ); Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.mother(), annDoe ) ) ); System.out.println( "*** script34: " + query ); verifyUnorderedResults( query, "Joe Doe" ); }
@Test public void script34() { QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Female annDoe = unitOfWork.get( Female.class, StringIdentity.identityOf( "anndoe" ) ); Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.mother(), annDoe ) ) ); System.out.println( "*** script34: " + query ); verifyUnorderedResults( query, "Joe Doe" ); }
@Test public void script36() { QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Account anns = unitOfWork.get( Account.class, StringIdentity.identityOf( "accountOfAnnDoe" ) ); Query<Person> query = unitOfWork.newQuery( qb.where( contains( person.accounts(), anns ) ) ); System.out.println( "*** script36: " + query ); verifyUnorderedResults( query, "Jack Doe", "Ann Doe" ); }
@Override public Person findPersonByName( String name ) { UnitOfWork uow = unitOfWorkFactory.currentUnitOfWork(); return uow.toValue( Person.class, uow.get( Person.class, StringIdentity.identityOf( name ) ) ); } }
@Test public void whenSettingAnAssociationInASideEffectExpectItToWork() { try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Purchase Steinway" ) ) ) { Pianist chris = uow.newEntity( Pianist.class, StringIdentity.identityOf( "Chris" ) ); Steinway modelD = uow.newEntity( Steinway.class, StringIdentity.identityOf( "ModelD-274" ) ); assertThat( modelD.owner().get(), is( nullValue() ) ); chris.purchase( modelD ); assertThat( modelD.owner().get(), is( theInstance( chris ) ) ); } }