http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java new file mode 100644 index 0000000..925e500 --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.legal; + +import java.math.BigDecimal; +import java.util.Map; +import org.apache.polygene.api.entity.EntityBuilder; +import org.apache.polygene.api.identity.Identity; +import org.apache.polygene.api.identity.StringIdentity; +import org.apache.polygene.api.injection.scope.Structure; +import org.apache.polygene.api.mixin.Mixins; +import org.apache.polygene.api.unitofwork.UnitOfWork; +import org.apache.polygene.api.unitofwork.UnitOfWorkFactory; +import org.apache.polygene.api.unitofwork.concern.UnitOfWorkPropagation; +import org.apache.polygene.api.value.ValueBuilder; +import org.apache.polygene.api.value.ValueBuilderFactory; +import org.apache.polygene.test.entity.model.people.Person; + +@Mixins( LegalService.Mixin.class ) +public interface LegalService +{ + @UnitOfWorkPropagation + Identity createWill( Person principal, Map<Person, BigDecimal> amounts, Map<Person, Float> percentages, Map<Person, String> specificItems ); + + class Mixin + implements LegalService + { + @Structure + private ValueBuilderFactory vbf; + + @Structure + private UnitOfWorkFactory uowf; + + @Override + public Identity createWill( Person principal, Map<Person, BigDecimal> amounts, Map<Person, Float> percentages, Map<Person, String> specificItems ) + { + UnitOfWork uow = uowf.currentUnitOfWork(); + Identity identity = StringIdentity.identity( "will-" + principal.name().get() ); + EntityBuilder<Will> builder = uow.newEntityBuilder( Will.class, identity ); + Will instance = builder.instance(); + for( Map.Entry<Person, BigDecimal> entry : amounts.entrySet() ) + { + WillAmount amount = createAmount( entry.getKey(), entry.getValue() ); + instance.amounts().add( amount ); + } + for( Map.Entry<Person, Float> entry : percentages.entrySet() ) + { + WillPercentage amount = createPercentage( entry.getKey(), entry.getValue() ); + instance.percentages().add( amount ); + } + for( Map.Entry<Person, String> entry : specificItems.entrySet() ) + { + String value = entry.getValue(); + int pos = value.indexOf( '\n' ); + String item = value.substring( 0, pos ); + String description = value.substring( pos + 1 ); + WillItem amount = createItem( entry.getKey(), item, description ); + instance.items().add( amount ); + } + builder.newInstance(); + return identity; + } + + private WillAmount createAmount( Person beneficiary, BigDecimal amount ) + { + ValueBuilder<WillAmount> builder = vbf.newValueBuilder( WillAmount.class ); + builder.prototype().amount().set( amount ); + builder.prototype().beneficiary().set( beneficiary ); + return builder.newInstance(); + } + + private WillPercentage createPercentage( Person beneficiary, Float percentage ) + { + ValueBuilder<WillPercentage> builder = vbf.newValueBuilder( WillPercentage.class ); + builder.prototype().percentage().set( percentage ); + builder.prototype().beneficiary().set( beneficiary ); + return builder.newInstance(); + } + + private WillItem createItem( Person beneficiary, String item, String description ) + { + ValueBuilder<WillItem> builder = vbf.newValueBuilder( WillItem.class ); + builder.prototype().item().set( item ); + builder.prototype().item().set( description ); + builder.prototype().beneficiary().set( beneficiary ); + return builder.newInstance(); + } + } +}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/Will.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/Will.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/Will.java new file mode 100644 index 0000000..1c66efb --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/Will.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.legal; + +import org.apache.polygene.api.association.Association; +import org.apache.polygene.api.association.ManyAssociation; +import org.apache.polygene.test.entity.model.people.Person; + +public interface Will +{ + + Association<Person> principal(); + + ManyAssociation<WillItem> items(); + + ManyAssociation<WillPercentage> percentages(); + + ManyAssociation<WillAmount> amounts(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillAmount.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillAmount.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillAmount.java new file mode 100644 index 0000000..6661375 --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillAmount.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.legal; + +import java.math.BigDecimal; +import org.apache.polygene.api.property.Property; + +public interface WillAmount extends WillBenefit +{ + Property<BigDecimal> amount(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillBenefit.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillBenefit.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillBenefit.java new file mode 100644 index 0000000..0347a6c --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillBenefit.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.legal; + +import org.apache.polygene.api.association.Association; +import org.apache.polygene.api.common.Optional; +import org.apache.polygene.api.property.Property; +import org.apache.polygene.test.entity.model.people.Person; + +public interface WillBenefit +{ + Association<Person> beneficiary(); + + @Optional + Property<String> condition(); + + @Optional + Association<Person> alternateBeneficiary(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillItem.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillItem.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillItem.java new file mode 100644 index 0000000..abcafe3 --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillItem.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.legal; + +import org.apache.polygene.api.property.Property; + +public interface WillItem extends WillBenefit +{ + Property<String> item(); + + Property<String> description(); + +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillPercentage.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillPercentage.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillPercentage.java new file mode 100644 index 0000000..dc34dd2 --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillPercentage.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.legal; + +import org.apache.polygene.api.property.Property; + +public interface WillPercentage extends WillBenefit +{ + Property<Float> percentage(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Address.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Address.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Address.java new file mode 100644 index 0000000..cc6a426 --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Address.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.people; + +import org.apache.polygene.api.association.Association; +import org.apache.polygene.api.identity.HasIdentity; +import org.apache.polygene.api.property.Property; + +public interface Address extends HasIdentity +{ + Property<Rent> rent(); + + Property<String> street(); + + Association<City> city(); + + Property<String> zipCode(); + + Association<Country> country(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/City.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/City.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/City.java new file mode 100644 index 0000000..25078c0 --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/City.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.people; + +import org.apache.polygene.api.identity.HasIdentity; +import org.apache.polygene.api.property.Property; + +public interface City extends HasIdentity +{ + Property<String> name(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Country.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Country.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Country.java new file mode 100644 index 0000000..cc0800b --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Country.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.people; + +import org.apache.polygene.api.identity.HasIdentity; +import org.apache.polygene.api.property.Property; + +public interface Country extends HasIdentity +{ + Property<String> name(); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PeopleRepository.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PeopleRepository.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PeopleRepository.java new file mode 100644 index 0000000..0aeb8ea --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PeopleRepository.java @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.people; + +import org.apache.polygene.api.common.Optional; +import org.apache.polygene.api.entity.EntityBuilder; +import org.apache.polygene.api.identity.Identity; +import org.apache.polygene.api.injection.scope.Structure; +import org.apache.polygene.api.mixin.Mixins; +import org.apache.polygene.api.unitofwork.UnitOfWork; +import org.apache.polygene.api.unitofwork.UnitOfWorkFactory; + +import static org.apache.polygene.api.identity.StringIdentity.identity; + +@Mixins( PeopleRepository.Mixin.class ) +public interface PeopleRepository +{ + Person createPerson( String name, Country nationality, @Optional Address address, @Optional Person spouse, @Optional PhoneNumber homeNumber ); + + void addChild( Person parent, Person child ); + + Person findPersonByName( String name ); + + Country createCountry( String countryCode, String countryName ); + + Country findCountryByCountryCode( String countryCode ); + + Country findCountryByIdentity( Identity countryId ); + + Address createAddress( String street, String zipCode, City city, Country country, Rent rent ); + + Address findAddress( Identity addressId ); + + City createCity( String cityName ); + + City findCity( Identity cityId ); + + PhoneNumber createPhoneNumber( String phoneNumberString ); + + PhoneNumber findPhoneNumberById( Identity phoneNumberId ); + + class Mixin + implements PeopleRepository + { + @Structure + private UnitOfWorkFactory uowf; + + @Override + public Person createPerson( String name, Country nationality, Address address, Person spouse, PhoneNumber homeNumber ) + { + UnitOfWork uow = uowf.currentUnitOfWork(); + EntityBuilder<Person> builder = uow.newEntityBuilder( Person.class, identity( "person-" + name ) ); + Person instance = builder.instance(); + instance.name().set( name ); + instance.nationality().set( nationality ); + instance.address().set( address ); + instance.spouse().set( spouse ); + if( homeNumber != null ) + { + instance.phoneNumbers().put( "Home", homeNumber ); + } + return builder.newInstance(); + } + + @Override + public void addChild( Person parent, Person child ) + { + parent.children().add( child ); + } + + @Override + public Person findPersonByName( String name ) + { + UnitOfWork uow = uowf.currentUnitOfWork(); + return uow.get( Person.class, identity( "person-" + name ) ); + } + + @Override + public Country createCountry( String countryCode, String countryName ) + { + UnitOfWork uow = uowf.currentUnitOfWork(); + EntityBuilder<Country> builder = uow.newEntityBuilder( Country.class, identity( "country-" + countryCode ) ); + builder.instance().name().set( countryName ); + return builder.newInstance(); + } + + @Override + public Country findCountryByCountryCode( String countryCode ) + { + + return findCountryByIdentity( identity( "country-" + countryCode ) ); + } + + @Override + public Country findCountryByIdentity( Identity countryId ) + { + UnitOfWork uow = uowf.currentUnitOfWork(); + return uow.get( Country.class, countryId ); + } + + @Override + public Address createAddress( String street, String zipCode, City city, Country country, Rent rent ) + { + UnitOfWork uow = uowf.currentUnitOfWork(); + EntityBuilder<Address> builder = uow.newEntityBuilder( Address.class ); + Address prototype = builder.instance(); + prototype.street().set( street ); + prototype.zipCode().set( zipCode ); + prototype.city().set( city ); + prototype.country().set( country ); + prototype.rent().set( rent ); + return builder.newInstance(); + } + + @Override + public Address findAddress( Identity addressId ) + { + UnitOfWork uow = uowf.currentUnitOfWork(); + return uow.get( Address.class, addressId ); + } + + @Override + public City createCity( String cityName ) + { + UnitOfWork uow = uowf.currentUnitOfWork(); + EntityBuilder<City> builder = uow.newEntityBuilder( City.class ); + builder.instance().name().set( cityName ); + return builder.newInstance(); + } + + @Override + public City findCity( Identity cityId ) + { + UnitOfWork uow = uowf.currentUnitOfWork(); + return uow.get( City.class, cityId ); + } + + @Override + public PhoneNumber createPhoneNumber( String phoneNumberString ) + { + UnitOfWork uow = uowf.currentUnitOfWork(); + EntityBuilder<PhoneNumber> builder = uow.newEntityBuilder( PhoneNumber.class ); + PhoneNumber prototype = builder.instance(); + + // Of course better parsing should be done for a real application. + int pos1 = phoneNumberString.indexOf( '-' ); + int pos2 = phoneNumberString.indexOf( '-', pos1 + 1 ); + String countryCode = phoneNumberString.substring( 1, pos1 ); + String areaCode = phoneNumberString.substring( pos1 + 1, pos2 ); + String number = phoneNumberString.substring( pos2 + 1 ); + + prototype.countryCode().set( Integer.parseInt( countryCode ) ); + prototype.areaCode().set( Integer.parseInt( areaCode ) ); + prototype.number().set( number ); + + return builder.newInstance(); + } + + @Override + public PhoneNumber findPhoneNumberById( Identity phoneNumberId ) + { + UnitOfWork uow = uowf.currentUnitOfWork(); + return uow.get( PhoneNumber.class, phoneNumberId ); + } + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Person.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Person.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Person.java new file mode 100644 index 0000000..ac110a0 --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Person.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.people; + +import org.apache.polygene.api.association.Association; +import org.apache.polygene.api.association.ManyAssociation; +import org.apache.polygene.api.association.NamedAssociation; +import org.apache.polygene.api.common.Optional; +import org.apache.polygene.api.entity.Aggregated; +import org.apache.polygene.api.identity.HasIdentity; +import org.apache.polygene.api.injection.scope.Service; +import org.apache.polygene.api.injection.scope.Structure; +import org.apache.polygene.api.mixin.Mixins; +import org.apache.polygene.api.property.Property; +import org.apache.polygene.api.unitofwork.UnitOfWorkFactory; +import org.apache.polygene.api.unitofwork.concern.UnitOfWorkPropagation; + +@Mixins( Person.Mixin.class ) +public interface Person extends HasIdentity +{ + @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY ) + void movedToNewAddress( String street, String zipCode, City city, Country country, Rent rent ); + + @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY ) + void amendAddress( String street, String zipCode, City city, Country country ); + + Property<String> name(); + + Association<Country> nationality(); + + @Aggregated + Association<Address> address(); + + @Optional + Association<Person> spouse(); + + ManyAssociation<Person> children(); + + @Aggregated + ManyAssociation<Address> oldAddresses(); + + NamedAssociation<Person> relationships(); + + @Aggregated + NamedAssociation<PhoneNumber> phoneNumbers(); + + abstract class Mixin + implements Person + { + @Structure + private UnitOfWorkFactory uowf; + + @Service + private PeopleRepository repository; + + @Override + public void movedToNewAddress( String street, String zipCode, City city, Country country, Rent rent ) + { + Address newAddress = repository.createAddress( street, zipCode, city, country, rent ); + Address oldAddress = address().get(); + oldAddresses().add( oldAddress ); + address().set( newAddress ); + } + + @Override + public void amendAddress( String street, String zipCode, City city, Country country ) + { + Address newAddress = repository.createAddress( street, zipCode, city, country, address().get().rent().get() ); + address().set( newAddress ); + } + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PhoneNumber.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PhoneNumber.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PhoneNumber.java new file mode 100644 index 0000000..c711eab --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PhoneNumber.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.people; + +import org.apache.polygene.api.identity.HasIdentity; +import org.apache.polygene.api.injection.scope.Structure; +import org.apache.polygene.api.property.Property; +import org.apache.polygene.api.value.ValueBuilder; +import org.apache.polygene.api.value.ValueBuilderFactory; + +public interface PhoneNumber extends HasIdentity +{ + Property<Integer> countryCode(); + + Property<Integer> areaCode(); + + Property<String> number(); + + class Builder + { + private final ValueBuilder<PhoneNumber> valueBuilder; + private final PhoneNumber prototype; + + public Builder( @Structure ValueBuilderFactory vbf ) + { + valueBuilder = vbf.newValueBuilder( PhoneNumber.class ); + prototype = valueBuilder.prototype(); + } + + PhoneNumber create( int countryCode, int areaCode, String number ) + { + prototype.countryCode().set( countryCode ); + prototype.areaCode().set( areaCode ); + prototype.number().set( number ); + return valueBuilder.newInstance(); + } + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Rent.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Rent.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Rent.java new file mode 100644 index 0000000..576b3dc --- /dev/null +++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Rent.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.test.entity.model.people; + +import java.math.BigDecimal; +import org.apache.polygene.api.injection.scope.Structure; +import org.apache.polygene.api.property.Property; +import org.apache.polygene.api.value.ValueBuilder; +import org.apache.polygene.api.value.ValueBuilderFactory; + +public interface Rent +{ + Property<BigDecimal> amount(); + + Property<String> currency(); + + class Builder + { + @Structure + private ValueBuilderFactory vbf; + + public Rent create( Integer amount, String currency ) + { + ValueBuilder<Rent> builder = vbf.newValueBuilder( Rent.class ); + Rent prototype = builder.prototype(); + prototype.amount().set( new BigDecimal( amount ) ); + prototype.currency().set( currency ); + return builder.newInstance(); + } + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java index 08abae0..0592b1d 100644 --- a/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java +++ b/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java @@ -465,7 +465,7 @@ public abstract class AbstractQueryTest { QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); - Domain gaming = unitOfWork.get( Domain.class, StringIdentity.fromString( "Gaming" ) ); + Domain gaming = unitOfWork.get( Domain.class, StringIdentity.identity( "Gaming" ) ); Query<Person> query = unitOfWork.newQuery( qb.where( contains( person.interests(), gaming ) ) ); System.out.println( "*** script33: " + query ); @@ -477,7 +477,7 @@ public abstract class AbstractQueryTest { QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); - Female annDoe = unitOfWork.get( Female.class, StringIdentity.fromString( "anndoe" ) ); + Female annDoe = unitOfWork.get( Female.class, StringIdentity.identity( "anndoe" ) ); Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.mother(), annDoe ) ) ); System.out.println( "*** script34: " + query ); @@ -500,7 +500,7 @@ public abstract class AbstractQueryTest { QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); - Account anns = unitOfWork.get( Account.class, StringIdentity.fromString( "accountOfAnnDoe" ) ); + Account anns = unitOfWork.get( Account.class, StringIdentity.identity( "accountOfAnnDoe" ) ); Query<Person> query = unitOfWork.newQuery( qb.where( contains( person.accounts(), anns ) ) ); System.out.println( "*** script36: " + query ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java b/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java index bc275bb..40df6ba 100644 --- a/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java +++ b/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java @@ -59,7 +59,7 @@ public class TestData NameableAssert.clear(); Domain gaming; { - EntityBuilder<Domain> domainBuilder = unitOfWork.newEntityBuilder( Domain.class, StringIdentity.fromString( "Gaming" ) ); + EntityBuilder<Domain> domainBuilder = unitOfWork.newEntityBuilder( Domain.class, StringIdentity.identity( "Gaming" ) ); gaming = domainBuilder.instance(); gaming.name().set( "Gaming" ); gaming.description().set( "Gaming domain" ); @@ -121,7 +121,7 @@ public class TestData Account annsAccount; { - EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, StringIdentity.fromString( "accountOfAnnDoe" ) ); + EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, StringIdentity.identity( "accountOfAnnDoe" ) ); annsAccount = accountBuilder.instance(); annsAccount.number().set( "accountOfAnnDoe" ); annsAccount = accountBuilder.newInstance(); @@ -129,7 +129,7 @@ public class TestData Account jacksAccount; { - EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, StringIdentity.fromString( "accountOfJackDoe" ) ); + EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, StringIdentity.identity( "accountOfJackDoe" ) ); jacksAccount = accountBuilder.instance(); jacksAccount.number().set( "accountOfJackDoe" ); jacksAccount = accountBuilder.newInstance(); @@ -143,7 +143,7 @@ public class TestData Female annDoe; { - EntityBuilder<Female> femaleBuilder = unitOfWork.newEntityBuilder( Female.class, StringIdentity.fromString( "anndoe" ) ); + EntityBuilder<Female> femaleBuilder = unitOfWork.newEntityBuilder( Female.class, StringIdentity.identity( "anndoe" ) ); annDoe = femaleBuilder.instance(); annDoe.name().set( "Ann Doe" ); annDoe.title().set( Person.Title.MRS ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java index 74c9e8c..f07a202 100644 --- a/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java +++ b/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java @@ -71,7 +71,7 @@ public abstract class AbstractPolygeneMetricsTest extends AbstractPolygeneBaseTe public interface PersonList { - Identity LIST_ID = StringIdentity.fromString( "person-list" ); + Identity LIST_ID = StringIdentity.identity( "person-list" ); ManyAssociation<Person> all(); } @@ -274,7 +274,7 @@ public abstract class AbstractPolygeneMetricsTest extends AbstractPolygeneBaseTe Commands commands = services.findService( Commands.class ).get(); Queries queries = services.findService( Queries.class ).get(); - Identity identity = StringIdentity.fromString( "1" ); + Identity identity = StringIdentity.identity( "1" ); try (UnitOfWork uow = services.unitOfWorkFactory().newUnitOfWork( newUsecase( "Step 1" ) ) ) { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java index 3741fd2..ddea6d2 100644 --- a/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java +++ b/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java @@ -253,7 +253,7 @@ public abstract class AbstractValueCompositeSerializationTest // JSONEntityState does not allow for polymorphic serialization public void valueAndEntityTypeEquality() { - Identity identity = StringIdentity.fromString( "42" ); + Identity identity = StringIdentity.identity( "42" ); Some createdValue, loadedValue; try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "create" ) ) ) @@ -301,7 +301,7 @@ public abstract class AbstractValueCompositeSerializationTest { EntityBuilder<Some> builder = uow.newEntityBuilder( Some.class ); Some proto = builder.instance(); - proto.identity().set( StringIdentity.fromString( identity ) ); + proto.identity().set( StringIdentity.identity( identity ) ); setSomeValueState( module, uow, proto ); return builder.newInstance(); } @@ -313,7 +313,7 @@ public abstract class AbstractValueCompositeSerializationTest { ValueBuilder<Some> builder = module.newValueBuilder( Some.class ); Some proto = builder.prototype(); - proto.identity().set( StringIdentity.fromString( identity ) ); + proto.identity().set( StringIdentity.identity( identity ) ); setSomeValueState( module, uow, proto ); return builder.newInstance(); } @@ -322,7 +322,7 @@ public abstract class AbstractValueCompositeSerializationTest { ValueBuilder<SomeExtended> builder = module.newValueBuilder( SomeExtended.class ); SomeExtended proto = builder.prototype(); - proto.identity().set( StringIdentity.fromString( identity ) ); + proto.identity().set( StringIdentity.identity( identity ) ); setSomeValueState( module, uow, proto ); proto.extraProperty().set( "extra property" ); proto.extraAssociation().set( buildBarEntity( module, uow, "extra association" ) ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java index cde443c..2895d53 100644 --- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java +++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java @@ -427,7 +427,7 @@ public class CassandraEntityStoreMixin Identity newIdentity; if( idGenerator == null ) { - newIdentity = StringIdentity.fromString( UUID.randomUUID().toString() ); + newIdentity = StringIdentity.identity( UUID.randomUUID().toString() ); } else { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/extensions/entitystore-jdbm/src/test/java/org/apache/polygene/entitystore/jdbm/JdbmEntityStoreTestSuite.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jdbm/src/test/java/org/apache/polygene/entitystore/jdbm/JdbmEntityStoreTestSuite.java b/extensions/entitystore-jdbm/src/test/java/org/apache/polygene/entitystore/jdbm/JdbmEntityStoreTestSuite.java new file mode 100644 index 0000000..597bfe3 --- /dev/null +++ b/extensions/entitystore-jdbm/src/test/java/org/apache/polygene/entitystore/jdbm/JdbmEntityStoreTestSuite.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.entitystore.jdbm; + +import org.apache.polygene.api.common.Visibility; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.entitystore.jdbm.assembly.JdbmEntityStoreAssembler; +import org.apache.polygene.library.fileconfig.FileConfigurationAssembler; +import org.apache.polygene.library.fileconfig.FileConfigurationOverride; +import org.apache.polygene.test.entity.model.EntityStoreTestSuite; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; + +public class JdbmEntityStoreTestSuite extends EntityStoreTestSuite +{ + @Rule + public final TemporaryFolder tmpDir = new TemporaryFolder(); + private ModuleAssembly configModule; + + @Override + protected void defineStorageModule( ModuleAssembly module ) + { + module.defaultServices(); + new FileConfigurationAssembler() + .withOverride( new FileConfigurationOverride().withConventionalRoot( tmpDir.getRoot() ) ) + .assemble( module ); + new JdbmEntityStoreAssembler().visibleIn( Visibility.application ) + .withConfig( configModule, Visibility.application ) + .assemble( module ); + } + + @Override + protected void defineConfigModule( ModuleAssembly module ) + { + configModule = module; + super.defineConfigModule( module ); + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java index 36fe4ee..6a41cea 100644 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java +++ b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java @@ -36,7 +36,7 @@ import org.jooq.conf.Settings; public abstract class AbstractSQLEntityStoreAssembler<AssemblerType> extends Assemblers.VisibilityIdentityConfig<AssemblerType> { - public static final Identity DEFAULT_ENTITYSTORE_IDENTITY = StringIdentity.fromString( "entitystore-sql" ); + public static final Identity DEFAULT_ENTITYSTORE_IDENTITY = StringIdentity.identity( "entitystore-sql" ); private static final String DEFAULT_CHANGELOG_PATH = "org/apache/polygene/entitystore/sql/changelog.xml"; private String changelogPath = DEFAULT_CHANGELOG_PATH; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java b/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java index 96abf69..08e1db4 100644 --- a/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java @@ -102,7 +102,7 @@ public class RDFPerformanceTest extends AbstractPolygeneTest List<ExampleEntity> entities = new ArrayList<ExampleEntity>(); for (Integer x = 0; x < howMany; ++x) { - ExampleEntity exampleEntity = this.unitOfWorkFactory.currentUnitOfWork().newEntity( ExampleEntity.class, StringIdentity.fromString( "entity" + x ) ); + ExampleEntity exampleEntity = this.unitOfWorkFactory.currentUnitOfWork().newEntity( ExampleEntity.class, StringIdentity.identity( "entity" + x ) ); for (ExampleEntity entity : entities) { @@ -188,7 +188,7 @@ public class RDFPerformanceTest extends AbstractPolygeneTest UnitOfWork uow = this.unitOfWorkFactory.newUnitOfWork(); for (int i = 0; i < 1000; i++) { - ExampleEntity entity50 = uow.get(ExampleEntity.class, StringIdentity.fromString( "entity50" ) ); + ExampleEntity entity50 = uow.get(ExampleEntity.class, StringIdentity.identity( "entity50" ) ); Query<ExampleEntity> query = uow.newQuery( this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class ). where( QueryExpressions.contains( QueryExpressions.templateFor( ExampleEntity.class ).manyAssoc(), entity50) )); System.out.println(query.count()); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java b/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java index d3675a3..86790c9 100644 --- a/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java +++ b/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java @@ -35,7 +35,7 @@ import org.apache.polygene.library.sql.generator.vendor.SQLVendorProvider; public abstract class AbstractSQLIndexQueryAssembler<AssemblerType> extends Assemblers.VisibilityIdentityConfig<AssemblerType> { - public static final Identity DEFAULT_IDENTITY = StringIdentity.fromString( "indexing-sql" ); + public static final Identity DEFAULT_IDENTITY = StringIdentity.identity( "indexing-sql" ); private Class<? extends ReindexingStrategy> reindexingStrategy = ReindexingStrategy.NeverNeed.class; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java ---------------------------------------------------------------------- diff --git a/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java b/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java index b275943..1b42452 100644 --- a/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java +++ b/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java @@ -214,7 +214,7 @@ public interface AlarmSystem public AlarmPoint createAlarm( String name, AlarmCategory category ) { UnitOfWork uow = uowf.currentUnitOfWork(); - EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class, StringIdentity.fromString( name ) ); + EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class, StringIdentity.identity( name ) ); builder.instance().category().set( category ); AlarmPoint.AlarmState state = builder.instanceFor( AlarmPoint.AlarmState.class ); state.systemName().set( name ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java ---------------------------------------------------------------------- diff --git a/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java b/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java index 30e9c35..5ec2236 100644 --- a/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java +++ b/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java @@ -60,7 +60,7 @@ public class AlarmProxyTest extends AbstractPolygeneTest try { // START SNIPPET: documentation - myAlarmPoint = factory.create( StringIdentity.fromString( "This Alarm Identity" ), "ProActiveCRM", "Sales", AlarmClass.B ); + myAlarmPoint = factory.create( StringIdentity.identity( "This Alarm Identity" ), "ProActiveCRM", "Sales", AlarmClass.B ); myAlarmPoint.history().maxSize().set( 20 ); // END SNIPPET: documentation @@ -71,7 +71,7 @@ public class AlarmProxyTest extends AbstractPolygeneTest assertThat( myAlarmPoint.history().activateCounter(), equalTo( 1 ) ); AlarmEvent event = myAlarmPoint.history().firstEvent(); assertThat( event, notNullValue() ); - assertThat( event.identity().get(), equalTo( StringIdentity.fromString( "This Alarm Identity" ) ) ); + assertThat( event.identity().get(), equalTo( StringIdentity.identity( "This Alarm Identity" ) ) ); assertThat( event.newStatus().get().name( null ), equalTo( "Activated" ) ); assertThat( event.oldStatus().get().name( null ), equalTo( "Normal" ) ); } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java ---------------------------------------------------------------------- diff --git a/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java b/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java index a8ce3bf..91025f0 100644 --- a/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java +++ b/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java @@ -243,7 +243,7 @@ public interface ConfigurationManagerService EditableConfiguration( MBeanInfo info, String identity, Map<String, AccessibleObject> propertyNames ) { this.info = info; - this.identity = StringIdentity.fromString(identity); + this.identity = StringIdentity.identity( identity ); this.propertyNames = propertyNames; } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java ---------------------------------------------------------------------- diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java index 59528e2..a48e272 100644 --- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java +++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java @@ -109,14 +109,14 @@ public class EntitySerializerTest valueBuilder.prototype().test3().set( valueBuilder2.newInstance() ); TestValue testValue = valueBuilder.newInstance(); - EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "test1" ) ); + EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identity( "test1" ) ); TestEntity rickardTemplate = builder.instance(); rickardTemplate.name().set( "Rickard" ); rickardTemplate.title().set( "Mr" ); rickardTemplate.value().set( testValue ); TestEntity testEntity = builder.newInstance(); - EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "test2" ) ); + EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identity( "test2" ) ); TestEntity niclasTemplate = builder2.instance(); niclasTemplate.name().set( "Niclas" ); niclasTemplate.title().set( "Mr" ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java ---------------------------------------------------------------------- diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java index e4a7efe..ae4c56e 100644 --- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java +++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java @@ -95,14 +95,14 @@ public class EntityTypeSerializerTest valueBuilder.prototype().test3().set( vb2.newInstance() ); TestValue testValue = valueBuilder.newInstance(); - EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder(TestEntity.class, StringIdentity.fromString( "test1") ); + EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder(TestEntity.class, StringIdentity.identity( "test1" ) ); TestEntity rickardTemplate = builder.instance(); rickardTemplate.name().set( "Rickard" ); rickardTemplate.title().set( "Mr" ); rickardTemplate.value().set( testValue ); TestEntity testEntity = builder.newInstance(); - EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder(TestEntity.class, StringIdentity.fromString( "test2") ); + EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder(TestEntity.class, StringIdentity.identity( "test2" ) ); TestEntity niclasTemplate = builder2.instance(); niclasTemplate.name().set( "Niclas" ); niclasTemplate.title().set( "Mr" ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java ---------------------------------------------------------------------- diff --git a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java index 7bfc77b..50db549 100644 --- a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java +++ b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java @@ -51,7 +51,7 @@ public class RequestReaderDelegator public void init( @Service Iterable<ServiceReference<RequestReader>> requestReaderReferences ) { Logger logger = LoggerFactory.getLogger( getClass() ); - Identity requestreaderdelegator = StringIdentity.fromString("requestreaderdelegator"); + Identity requestreaderdelegator = StringIdentity.identity( "requestreaderdelegator" ); // Add custom readers first for( ServiceReference<RequestReader> requestReader : requestReaderReferences ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java ---------------------------------------------------------------------- diff --git a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java index 14279c8..5809f66 100644 --- a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java +++ b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java @@ -48,7 +48,7 @@ public class ResponseWriterDelegator public void init( @Service Iterable<ServiceReference<ResponseWriter>> resultWriters ) { Logger logger = LoggerFactory.getLogger( getClass() ); - Identity responsewriterdelegator = StringIdentity.fromString( "responsewriterdelegator" ); + Identity responsewriterdelegator = StringIdentity.identity( "responsewriterdelegator" ); // Add custom writers first for( ServiceReference<ResponseWriter> resultWriter : resultWriters ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java ---------------------------------------------------------------------- diff --git a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java index 8ed1666..65b31af 100644 --- a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java +++ b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java @@ -251,7 +251,7 @@ public class DefaultRequestReader entityAsForm = new Form(); } - Identity entityIdentity = StringIdentity.fromString( getValue( "entity", queryAsForm, entityAsForm ) ); + Identity entityIdentity = StringIdentity.identity( getValue( "entity", queryAsForm, entityAsForm ) ); args[0] = uowf.currentUnitOfWork().get( method.getParameterTypes()[0], entityIdentity ); return args; @@ -480,7 +480,7 @@ public class DefaultRequestReader } else if( parameterType.isInterface() ) { - arg = uowf.currentUnitOfWork().get( parameterType, StringIdentity.fromString( argString ) ); + arg = uowf.currentUnitOfWork().get( parameterType, StringIdentity.identity( argString ) ); } else { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java ---------------------------------------------------------------------- diff --git a/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java b/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java index 5401a54..a81e682 100644 --- a/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java +++ b/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java @@ -106,7 +106,7 @@ public class EntityResource { // /entity/{reference} Map<String, Object> attributes = getRequest().getAttributes(); - identity = StringIdentity.fromString( (String) attributes.get( "reference" ) ); + identity = StringIdentity.identity( (String) attributes.get( "reference" ) ); } @Override http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java ---------------------------------------------------------------------- diff --git a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java index 14387d1..56004c4 100644 --- a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java +++ b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java @@ -77,13 +77,13 @@ public interface DummyDataService valueBuilder.prototype().string().set( "Foo bar value" ); valueBuilder.prototype().map().set( new HashMap() ); - EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "test1" ) ); + EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identity( "test1" ) ); builder.instance().name().set( "Foo bar" ); builder.instance().age().set( 42 ); builder.instance().value().set( valueBuilder.newInstance() ); TestEntity testEntity = builder.newInstance(); - EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "test2" ) ); + EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identity( "test2" ) ); builder2.instance().name().set( "Xyzzy" ); builder2.instance().age().set( 12 ); builder2.instance().association().set( testEntity ); @@ -98,7 +98,7 @@ public interface DummyDataService } { - EntityBuilder<TestEntity2> builder = unitOfWork.newEntityBuilder( TestEntity2.class, StringIdentity.fromString( "test3" ) ); + EntityBuilder<TestEntity2> builder = unitOfWork.newEntityBuilder( TestEntity2.class, StringIdentity.identity( "test3" ) ); builder.instance().name().set( "Test3" ); builder.newInstance(); } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java ---------------------------------------------------------------------- diff --git a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java index 0364d18..206c0ef 100644 --- a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java +++ b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java @@ -111,13 +111,13 @@ public class RestTest extends AbstractPolygeneTest UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); try { - EntityBuilder<PersonEntity> builder1 = uow.newEntityBuilder( PersonEntity.class, StringIdentity.fromString( "P2" ) ); + EntityBuilder<PersonEntity> builder1 = uow.newEntityBuilder( PersonEntity.class, StringIdentity.identity( "P2" ) ); PersonEntity maryDoe = builder1.instance(); maryDoe.firstname().set( "Mary" ); maryDoe.lastname().set( "Doe" ); maryDoe = builder1.newInstance(); - EntityBuilder<PersonEntity> builder2 = uow.newEntityBuilder( PersonEntity.class, StringIdentity.fromString( "P1" ) ); + EntityBuilder<PersonEntity> builder2 = uow.newEntityBuilder( PersonEntity.class, StringIdentity.identity( "P1" ) ); PersonEntity joeDoe = builder2.instance(); joeDoe.firstname().set( "Joe" ); joeDoe.lastname().set( "Doe" ); @@ -162,7 +162,7 @@ public class RestTest extends AbstractPolygeneTest UnitOfWork work = unitOfWorkFactory.newUnitOfWork(); try { - PersonEntity entity = work.get( PersonEntity.class, StringIdentity.fromString( "P1" ) ); + PersonEntity entity = work.get( PersonEntity.class, StringIdentity.identity( "P1" ) ); assertEquals( "FirstName not changed.", "Jack", entity.firstname().get() ); assertEquals( "LastName not changed.", "Doe", entity.lastname().get() ); work.complete(); @@ -185,7 +185,7 @@ public class RestTest extends AbstractPolygeneTest PersonEntity entity = null; try { - entity = work.get( PersonEntity.class, StringIdentity.fromString( "P1" ) ); + entity = work.get( PersonEntity.class, StringIdentity.identity( "P1" ) ); } catch( NoSuchEntityException expected ) { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java ---------------------------------------------------------------------- diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java index 8ed6fb1..c822892 100644 --- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java +++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java @@ -97,7 +97,7 @@ public interface EntityResource<T extends HasIdentity> extends ServerResource<T> { Class entityType = parameters.entityType().get(); String idOfEntity = parameters.id().get(); - locator.find( entityType ).delete( StringIdentity.fromString( idOfEntity ) ); + locator.find( entityType ).delete( StringIdentity.identity( idOfEntity ) ); } @Override @@ -137,7 +137,7 @@ public interface EntityResource<T extends HasIdentity> extends ServerResource<T> throw new RuntimeException( message, e ); } Reference base = parameters.request().get().getResourceRef(); - return resourceBuilder.createRestLink( StringIdentity.fromString( "" ), base, org.restlet.data.Method.GET ); + return resourceBuilder.createRestLink( StringIdentity.identity( "" ), base, org.restlet.data.Method.GET ); } private Object createParametersComposite( RestForm form, Class argType ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java ---------------------------------------------------------------------- diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java index b41df0c..ec2a6c0 100644 --- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java +++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java @@ -80,10 +80,10 @@ public interface IdentityManager if( isIdentity( canonicalName ) ) { // This is already an ID, and we simply return it. - return StringIdentity.fromString( canonicalName ); + return StringIdentity.identity( canonicalName ); } String prefix = findPrefix( type ); - return StringIdentity.fromString( prefix + SEPARATOR + canonicalName ); + return StringIdentity.identity( prefix + SEPARATOR + canonicalName ); } @Override http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java ---------------------------------------------------------------------- diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java index 274ea9e..2204980 100644 --- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java +++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java @@ -80,18 +80,18 @@ public interface EntryPointResource extends ServerResource<EntryPoint> RestLink link; if( route.getDescription() == null ) { - link = resourceBuilder.createRestLink( StringIdentity.fromString( template.getPattern() ), hostRef, Method.GET ); + link = resourceBuilder.createRestLink( StringIdentity.identity( template.getPattern() ), hostRef, Method.GET ); } else { - link = resourceBuilder.createRestLink( StringIdentity.fromString( template.getPattern() ), hostRef, Method.GET, route.getDescription() ); + link = resourceBuilder.createRestLink( StringIdentity.identity( template.getPattern() ), hostRef, Method.GET, route.getDescription() ); } entryPoints.put( route.getName(), link ); } } } ValueBuilder<EntryPoint> builder = vbf.newValueBuilder( EntryPoint.class ); - builder.prototype().identity().set( StringIdentity.fromString( "/" ) ); + builder.prototype().identity().set( StringIdentity.identity( "/" ) ); builder.prototype().api().set( entryPoints ); return builder.newInstance(); } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java ---------------------------------------------------------------------- diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java index eb46bac..b59aac8 100644 --- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java +++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java @@ -143,7 +143,7 @@ public interface ResourceBuilder public RestForm createNameForm( Reference base ) { ValueBuilder<RestForm> builder = vbf.newValueBuilder( RestForm.class ); - builder.prototype().link().set( createRestLink( StringIdentity.fromString( "form" ), base, Method.POST ) ); + builder.prototype().link().set( createRestLink( StringIdentity.identity( "form" ), base, Method.POST ) ); builder.prototype().fields().set( Collections.singletonList( createFormField( "name", FormField.TEXT ) ) ); return builder.newInstance(); } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java ---------------------------------------------------------------------- diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java index 31cb4bc..e3d8e73 100644 --- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java +++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java @@ -70,7 +70,7 @@ public class DataSourceAssembler { module.importedServices( DataSource.class ). importedBy( ServiceInstanceImporter.class ). - setMetaInfo( StringIdentity.fromString( dataSourceServiceId ) ). + setMetaInfo( StringIdentity.identity( dataSourceServiceId ) ). identifiedBy( identity() ). visibleIn( visibility() ); if( circuitBreaker != null ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java ---------------------------------------------------------------------- diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java index ef6b93d..78cf765 100644 --- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java +++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java @@ -65,7 +65,7 @@ public class ExternalDataSourceAssembler { if( circuitBreaker != null ) { - externalDataSource = DataSources.wrapWithCircuitBreaker( StringIdentity.fromString(identity()), externalDataSource, circuitBreaker ); + externalDataSource = DataSources.wrapWithCircuitBreaker( StringIdentity.identity( identity() ), externalDataSource, circuitBreaker ); } module.importedServices( DataSource.class ). identifiedBy( identity() ). http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java ---------------------------------------------------------------------- diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java index e008589..ec49c23 100644 --- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java +++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java @@ -175,7 +175,7 @@ public interface DataSourceConfigurationManagerService EditableConfiguration( MBeanInfo info, String identity, Map<String, AccessibleObject> propertyNames ) { this.info = info; - this.identity = StringIdentity.fromString( identity ); + this.identity = StringIdentity.identity( identity ); this.propertyNames = propertyNames; } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java ---------------------------------------------------------------------- diff --git a/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java b/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java index 5e7043f..9bd5878 100644 --- a/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java +++ b/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java @@ -133,8 +133,8 @@ public class PayBillsContext { // Creditor retrieval could be a use case in itself... List<BalanceData> creditors = new ArrayList<BalanceData>(); - creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.fromString( "BakerAccount" ) ) ); - creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.fromString( "ButcherAccount" ) ) ); + creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.identity( "BakerAccount" ) ) ); + creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.identity( "ButcherAccount" ) ) ); return creditors; } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java ---------------------------------------------------------------------- diff --git a/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java b/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java index 9a4fe3e..ba5a40d 100644 --- a/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java +++ b/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java @@ -126,8 +126,8 @@ public class PayBillsContext2 { // Creditor retrieval could be a use case in itself... List<BalanceData> creditors = new ArrayList<>(); - creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.fromString( "BakerAccount" ) ) ); - creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.fromString( "ButcherAccount" ) ) ); + creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.identity( "BakerAccount" ) ) ); + creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.identity( "ButcherAccount" ) ) ); return creditors; } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java ---------------------------------------------------------------------- diff --git a/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java b/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java index 1e69a86..4456660 100644 --- a/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java +++ b/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java @@ -24,9 +24,9 @@ import org.apache.polygene.api.identity.StringIdentity; public interface AccountIds { - Identity SAVINGS_ACCOUNT_ID = StringIdentity.fromString( "SavingsAccountId" ); - Identity CHECKING_ACCOUNT_ID = StringIdentity.fromString( "CheckingAccountId" ); - Identity CREDITOR_ID1 = StringIdentity.fromString( "BakerAccount" ); - Identity CREDITOR_ID2 = StringIdentity.fromString( "ButcherAccount" ); + Identity SAVINGS_ACCOUNT_ID = StringIdentity.identity( "SavingsAccountId" ); + Identity CHECKING_ACCOUNT_ID = StringIdentity.identity( "CheckingAccountId" ); + Identity CREDITOR_ID1 = StringIdentity.identity( "BakerAccount" ); + Identity CREDITOR_ID2 = StringIdentity.identity( "ButcherAccount" ); } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java ---------------------------------------------------------------------- diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java index 5650376..cc70100 100644 --- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java +++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java @@ -38,7 +38,7 @@ import static org.apache.polygene.api.query.QueryExpressions.templateFor; public interface Forums extends Administrators, EntityComposite { - Identity FORUMS_ID = StringIdentity.fromString( "forums" ); + Identity FORUMS_ID = StringIdentity.identity( "forums" ); Query<Forum> forums(); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java ---------------------------------------------------------------------- diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java index 42f0205..aa16c40 100644 --- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java +++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java @@ -41,7 +41,7 @@ import static org.apache.polygene.api.query.QueryExpressions.templateFor; public interface Users extends EntityComposite, Events { - Identity USERS_ID = StringIdentity.fromString( "users" ); + Identity USERS_ID = StringIdentity.identity( "users" ); Query<User> users(); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java ---------------------------------------------------------------------- diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java index 7dd3e52..f748192 100644 --- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java +++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java @@ -37,7 +37,7 @@ public class BoardResource public void resource( String segment ) throws ResourceException { - selectFromManyAssociation( ObjectSelection.current().get( Forum.class ).boards(), StringIdentity.fromString( segment ) ); + selectFromManyAssociation( ObjectSelection.current().get( Forum.class ).boards(), StringIdentity.identity( segment ) ); subResource( BoardResource.class ); } }
