http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvent.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvent.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvent.java deleted file mode 100644 index 057ea23..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvent.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.data.shipping.handling; - -import java.time.LocalDate; -import org.apache.zest.api.association.Association; -import org.apache.zest.api.common.Optional; -import org.apache.zest.api.common.UseDefaults; -import org.apache.zest.api.entity.Identity; -import org.apache.zest.api.property.Immutable; -import org.apache.zest.api.property.Property; -import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId; -import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location; -import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage; - -/** - * A HandlingEvent is used to register the event when, for instance, - * a cargo is unloaded from a carrier at some location at a given time. - * - * The HandlingEvent's are sent from different Incident Logging Applications - * some time after the event occurred and contain information about the - * {@link TrackingId}, {@link Location}, timestamp of the completion of the event, - * and possibly, if applicable a {@link Voyage}. - * - * HandlingEvent's could contain information about a {@link Voyage} and if so, - * the event type must be either {@link HandlingEventType#LOAD} or - * {@link HandlingEventType#UNLOAD}. - * - * All other events must be of {@link HandlingEventType#RECEIVE}, - * {@link HandlingEventType#CLAIM} or {@link HandlingEventType#CUSTOMS}. - * (Handling event type is mandatory). - */ -public interface HandlingEvent extends Identity -{ - @Immutable - Property<LocalDate> registrationDate(); - - @Immutable - Property<LocalDate> completionDate(); - - @Immutable - Property<TrackingId> trackingId(); - - @Immutable - Property<HandlingEventType> handlingEventType(); - - @Immutable - Association<Location> location(); - - @Optional - @Immutable - Association<Voyage> voyage(); - - @Optional - @UseDefaults - Property<Boolean> wasUnexpected(); -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEventType.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEventType.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEventType.java deleted file mode 100644 index c826d3e..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEventType.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.data.shipping.handling; - -/** - * A handling event type either requires or prohibits a voyage association. - */ -public enum HandlingEventType -{ - RECEIVE( false ), - LOAD( true ), - UNLOAD( true ), - CUSTOMS( false ), - CLAIM( false ); - - private final boolean voyageRequired; - - /** - * Private enum constructor. - * - * @param voyageRequired whether or not a voyage is associated with this event type - */ - private HandlingEventType( final boolean voyageRequired ) - { - this.voyageRequired = voyageRequired; - } - - /** - * @return True if a voyage association is required for this event type. - */ - public boolean requiresVoyage() - { - return voyageRequired; - } - - /** - * @return True if a voyage association is prohibited for this event type. - */ - public boolean prohibitsVoyage() - { - return !requiresVoyage(); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvents.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvents.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvents.java deleted file mode 100644 index 2a11e11..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvents.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.data.shipping.handling; - -import java.time.LocalDate; -import org.apache.zest.api.common.Optional; -import org.apache.zest.api.entity.EntityBuilder; -import org.apache.zest.api.injection.scope.Structure; -import org.apache.zest.api.mixin.Mixins; -import org.apache.zest.api.unitofwork.UnitOfWork; -import org.apache.zest.api.unitofwork.UnitOfWorkFactory; -import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId; -import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location; -import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage; - -/** - * HandlingEvent "collection" - could have had a many-association to - * Handling Events if it was part of the domain model. - */ -@Mixins( HandlingEvents.Mixin.class ) -public interface HandlingEvents -{ - String HANDLING_EVENTS_ID = "Handling_events_id"; - - HandlingEvent createHandlingEvent( LocalDate registrationDate, - LocalDate completionDate, - TrackingId trackingId, - HandlingEventType handlingEventType, - Location location, - @Optional Voyage voyage - ) - throws IllegalArgumentException; - - public abstract class Mixin - implements HandlingEvents - { - @Structure - UnitOfWorkFactory uowf; - - public HandlingEvent createHandlingEvent( LocalDate registrationDate, - LocalDate completionDate, - TrackingId trackingId, - HandlingEventType handlingEventType, - Location location, - Voyage voyage - ) - throws IllegalArgumentException - { - if( voyage == null && handlingEventType.requiresVoyage() ) - { - throw new IllegalArgumentException( "Voyage is required for handling event type " + handlingEventType ); - } - - else if( voyage != null && handlingEventType.prohibitsVoyage() ) - { - throw new IllegalArgumentException( "Voyage is not allowed with handling event type " + handlingEventType ); - } - - UnitOfWork uow = uowf.currentUnitOfWork(); - EntityBuilder<HandlingEvent> handlingEventBuilder = uow.newEntityBuilder( HandlingEvent.class ); - handlingEventBuilder.instance().registrationDate().set( registrationDate ); - handlingEventBuilder.instance().completionDate().set( completionDate ); - handlingEventBuilder.instance().trackingId().set( trackingId ); - handlingEventBuilder.instance().handlingEventType().set( handlingEventType ); - handlingEventBuilder.instance().location().set( location ); - handlingEventBuilder.instance().voyage().set( voyage ); // could be null - - // Save and return - return handlingEventBuilder.newInstance(); - } - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Itinerary.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Itinerary.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Itinerary.java deleted file mode 100644 index 90b4228..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Itinerary.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.data.shipping.itinerary; - -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.List; -import org.apache.zest.api.mixin.Mixins; -import org.apache.zest.api.property.Property; -import org.apache.zest.library.constraints.annotation.NotEmpty; - -import static java.time.ZoneOffset.UTC; - -/** - * An itinerary is a description of a planned route for a cargo. - * - * The itinerary has a list of Legs each describing expected - * loading onto/ unloading from voyages at different locations. - * - * List of legs is mandatory and immutable. - */ -@Mixins( Itinerary.Mixin.class ) -public interface Itinerary -{ - @NotEmpty - Property<List<Leg>> legs(); - - // Side-effects free and UI agnostic convenience methods - Leg firstLeg(); - - Leg lastLeg(); - - LocalDate finalArrivalDate(); - - long days(); - - public abstract class Mixin - implements Itinerary - { - public Leg firstLeg() - { - if( legs().get().isEmpty() ) - { - return null; - } - - return legs().get().get( 0 ); - } - - public Leg lastLeg() - { - if( legs().get().isEmpty() ) - { - return null; - } - - return legs().get().get( legs().get().size() - 1 ); - } - - public LocalDate finalArrivalDate() - { - if( lastLeg() == null ) - { - return LocalDate.MAX; - } - - return lastLeg().unloadDate().get(); - } - - public long days() - { - LocalDate dep = firstLeg().loadDate().get(); - LocalDate arr = lastLeg().unloadDate().get(); - return Duration.between(dep, arr).toDays(); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java deleted file mode 100644 index 8c985a2..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.data.shipping.itinerary; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import org.apache.zest.api.association.Association; -import org.apache.zest.api.property.Property; -import org.apache.zest.api.value.ValueComposite; -import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location; -import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage; - -/** - * A leg describes an expected segment of a route: - * - loading onto a voyage at a load location - * - unloading from the voyage at a unload location - * - * All properties are mandatory and immutable. - */ -public interface Leg -{ - Association<Location> loadLocation(); - - Property<LocalDate> loadDate(); - - Association<Voyage> voyage(); - - Property<LocalDate> unloadDate(); - - Association<Location> unloadLocation(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/Location.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/Location.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/Location.java deleted file mode 100644 index 8d86b68..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/Location.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.data.shipping.location; - -import org.apache.zest.api.mixin.Mixins; -import org.apache.zest.api.property.Immutable; -import org.apache.zest.api.property.Property; - -/** - * A location is stops on a journey, such as cargo - * origin or destination, or carrier movement endpoints. - * - * It is uniquely identified by a {@link UnLocode}. - * - * All properties are mandatory and immutable. - */ -@Immutable -@Mixins( Location.Mixin.class ) -public interface Location -{ - Property<UnLocode> unLocode(); - - Property<String> name(); - - // Side-effects free and UI agnostic convenience methods - String getCode(); - - String getString(); - - abstract class Mixin - implements Location - { - public String getCode() - { - return unLocode().get().code().get(); - } - - public String getString() - { - return name().get() + " (" + getCode() + ")"; - } - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/UnLocode.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/UnLocode.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/UnLocode.java deleted file mode 100644 index f0ee71f..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/UnLocode.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.data.shipping.location; - -import org.apache.zest.api.property.Property; -import org.apache.zest.api.value.ValueComposite; -import org.apache.zest.library.constraints.annotation.Matches; - -/** - * United Nations location code. - * - * http://www.unece.org/cefact/locode/ - * http://www.unece.org/cefact/locode/DocColumnDescription.htm#LOCODE - * - * UnLocode is mandatory and immutable. - */ -public interface UnLocode -{ - // Country code is exactly two letters. - // Location code is usually three letters, but may contain the numbers 2-9 as well - @Matches( "[a-zA-Z]{2}[a-zA-Z2-9]{3}" ) - Property<String> code(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java deleted file mode 100644 index b48b5fd..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.data.shipping.voyage; - -import java.time.LocalDate; -import org.apache.zest.api.association.Association; -import org.apache.zest.api.property.Property; -import org.apache.zest.api.value.ValueComposite; -import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location; - -/** - * A carrier movement is a vessel voyage from one location to another. - * - * All properties are mandatory and immutable. - */ -public interface CarrierMovement -{ - Association<Location> departureLocation(); - - Association<Location> arrivalLocation(); - - Property<LocalDate> departureDate(); - - Property<LocalDate> arrivalDate(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Schedule.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Schedule.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Schedule.java deleted file mode 100644 index f13c682..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Schedule.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.data.shipping.voyage; - -import java.util.List; -import org.apache.zest.api.property.Property; -import org.apache.zest.api.value.ValueComposite; - -/** - * A schedule is a series of {@link CarrierMovement}s. - * - * List of carrier movements is mandatory and immutable. - */ -public interface Schedule -{ - Property<List<CarrierMovement>> carrierMovements(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Voyage.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Voyage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Voyage.java deleted file mode 100644 index 88a8a53..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Voyage.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.data.shipping.voyage; - -import org.apache.zest.api.property.Property; - -/** - * A voyage is a ship, train, flight etc carrying a cargo from one location - * to another. A {@link Schedule} describes the route it takes. - * - * A cargo can be loaded onto part of, or the whole voyage. - * - * All properties are mandatory and immutable. - */ -public interface Voyage -{ - Property<VoyageNumber> voyageNumber(); - - Property<Schedule> schedule(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/VoyageNumber.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/VoyageNumber.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/VoyageNumber.java deleted file mode 100644 index 9571cb1..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/VoyageNumber.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.data.shipping.voyage; - -import org.apache.zest.api.property.Property; -import org.apache.zest.api.value.ValueComposite; - -/** - * Identifies a {@link Voyage}. - * - * Voyage number is mandatory and immutable. - */ -public interface VoyageNumber -{ - Property<String> number(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/WicketZestApplication.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/WicketZestApplication.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/WicketZestApplication.java deleted file mode 100644 index 696a67f..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/WicketZestApplication.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure; - -import javax.servlet.http.HttpServletRequest; -import org.apache.wicket.Page; -import org.apache.wicket.protocol.http.WebApplication; -import org.apache.wicket.request.cycle.AbstractRequestCycleListener; -import org.apache.wicket.request.cycle.RequestCycle; -import org.apache.zest.api.ZestAPI; -import org.apache.zest.api.composite.TransientBuilderFactory; -import org.apache.zest.api.injection.scope.Service; -import org.apache.zest.api.injection.scope.Structure; -import org.apache.zest.api.query.QueryBuilderFactory; -import org.apache.zest.api.structure.Application; -import org.apache.zest.api.structure.Module; -import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException; -import org.apache.zest.api.unitofwork.UnitOfWork; -import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException; -import org.apache.zest.api.unitofwork.UnitOfWorkFactory; -import org.apache.zest.api.usecase.UsecaseBuilder; -import org.apache.zest.api.value.ValueBuilderFactory; -import org.apache.zest.bootstrap.ApplicationAssembler; -import org.apache.zest.bootstrap.Energy4Java; -import org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.Context; -import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.Queries; -import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.ReadOnlyModel; -import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.page.BaseWebPage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Base Wicket Web Application containing the Zest application. - */ -public class WicketZestApplication - extends WebApplication -{ - public Logger logger = LoggerFactory.getLogger( WicketZestApplication.class ); - - protected Application zestApp; - protected Module zestModule; - - @Structure - protected UnitOfWorkFactory uowf; - - @Structure - protected ValueBuilderFactory vbf; - - @Structure - protected QueryBuilderFactory qbf; - - @Structure - protected TransientBuilderFactory tbf; - - @Structure - protected ZestAPI api; - - /** - * Zest Assembler - * - * To let the custom application class (DCISampleApplication_x) focus on starting up the - * Wicket environment, I made a convention of having Zest Assembler files in an 'assembly' - * folder beside the custom application class. - * - * There's always only one application file, but we could split the assemblage into several - * files ie. one for each layer. In that case, the Assembler file would be distributing to - * the individual LayerXAssembler classes. - * - * If you like, you can also override this method in the custom application class and simply - * return an instance of YourAssembler: - * - * @Override protected ApplicationAssembler getAssembler() { - * return new YourAssemblerInAnyPath(); - * } - */ - protected ApplicationAssembler getAssembler() - throws Exception - { - String appPath = getClass().getCanonicalName(); - String expectedPathFromApplication = ".assembly.Assembler"; - String assemblerPath = appPath.substring( 0, appPath.lastIndexOf( "." ) ) + expectedPathFromApplication; - try - { - return (ApplicationAssembler) Class.forName( assemblerPath ).newInstance(); - } - catch( ClassNotFoundException e ) - { - throw new Exception( "Couldn't find Zest assembler in path '" + assemblerPath + "'" ); - } - } - - protected String defaultLayerName() - { - return "BOOTSTRAP"; - } - - protected String defaultModuleName() - { - return "BOOTSTRAP-Bootstrap"; - } - - // Override this to bootstrap the wicket application - protected void wicketInit() - { - } - - @Override - protected void init() - { - startZest(); - handleUnitOfWork(); - - Context.prepareContextBaseClass( uowf ); - BaseWebPage.prepareBaseWebPageClass( tbf ); - ReadOnlyModel.prepareModelBaseClass( zestModule, api ); - Queries.prepareQueriesBaseClass( uowf, qbf ); - - wicketInit(); - } - - private void startZest() - { - try - { - logger.info( "Starting Zest application" ); - Energy4Java zest = new Energy4Java(); - zestApp = zest.newApplication( getAssembler() ); - zestApp.activate(); - zestModule = zestApp.findModule( defaultLayerName(), defaultModuleName() ); - - // Zest injects @Structure and @Service elements into this application instance - //zestModule.newObject( WicketZestApplication.class ); - zestModule.injectTo( this ); - - logger.info( "Started Zest application" ); - } - catch( Exception e ) - { - logger.error( "Could not start Zest application." ); - e.printStackTrace(); - System.exit( 100 ); - } - } - - private void handleUnitOfWork() - { - getRequestCycleListeners().add( new AbstractRequestCycleListener() - { - @Override - public void onBeginRequest( final RequestCycle requestCycle ) - { - super.onBeginRequest( requestCycle ); - - logger.debug( "================================" ); - logger.debug( "REQUEST start" ); - logger.debug( requestCycle.getRequest().toString() ); - logger.debug( requestCycle.getRequest().getRequestParameters().toString() ); - - UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "REQUEST" ) ); - logger.debug( " ### NEW " + uow + " ### MODULE: " + zestModule ); - } - - @Override - public void onEndRequest( final RequestCycle requestCycle ) - { - UnitOfWork uow = uowf.currentUnitOfWork(); - if( uow != null ) - { - try - { - if( "POST".equals( ( (HttpServletRequest) requestCycle.getRequest() - .getContainerRequest() ).getMethod() ) ) - { - // "Save" - logger.debug( " ### COMPLETE " + uow + " ### MODULE: " + zestModule ); - uow.complete(); - } - else - { - // GET requests - logger.debug( " ### DISCARD " + uow + " ### MODULE: " + zestModule ); - uow.discard(); - } - } - catch( ConcurrentEntityModificationException e ) - { - logger.error( " ### DISCARD " + uow + " ### MODULE: " + zestModule ); - uow.discard(); - e.printStackTrace(); - } - catch( UnitOfWorkCompletionException e ) - { - logger.error( " ### DISCARD " + uow + " ### MODULE: " + zestModule ); - uow.discard(); - e.printStackTrace(); - } - } - logger.debug( "REQUEST end" ); - logger.debug( "------------------------------------" ); - } - } ); - } - - // Since Zest can only add concrete classes in the assembly, we need to implement a (dummy) getHomePage() - // method here. Override in wicket application class with a real returned page class. - @Override - public Class<? extends Page> getHomePage() - { - return null; - } - - @Override - protected void onDestroy() - { - if( zestApp == null ) - { - return; - } - - try - { - logger.info( "Passivating Zest application" ); - zestApp.passivate(); - } - catch( Exception e ) - { - e.printStackTrace(); - } - } - - public String appVersion() - { - return zestApp.version(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/DTO.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/DTO.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/DTO.java deleted file mode 100644 index 6f0434b..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/DTO.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.conversion; - -import org.apache.zest.api.property.Immutable; -import org.apache.zest.api.value.ValueComposite; - -/** - * ValueComposites that extend DTO are candidates to have association types converted and assigned - */ -@Immutable -public interface DTO extends ValueComposite -{ -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/dci/Context.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/dci/Context.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/dci/Context.java deleted file mode 100644 index bb0c346..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/dci/Context.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.dci; - -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import org.apache.zest.api.unitofwork.UnitOfWorkFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Context - * - * Base class for DCI contexts. - * - * Helps assigning Entity objects to Roles and to "inject" the Context object into Methodful Roles. - */ -public abstract class Context -{ - protected Logger logger = LoggerFactory.getLogger( getClass() ); - - protected static UnitOfWorkFactory uowf; - - /* - * Role assignment + Context "injection" - * - * Cast a Data object to a Role, set the Context object in the Role and return the RolePlayer. - * - * Requirements: - * 1) SomeRole interface declares a 'void setContext(YourContext context);' method - * 2) SomeRole.Mixin class extends RoleMixin<YourContext> - * - * The RolePlayer can then use the context pointer to lookup other Roles in the current Context. - */ - protected <T> T rolePlayer( Class<T> roleClass, Object dataObject ) - { - if( dataObject == null ) - { - return null; - } - - objectCanPlayRole( roleClass, dataObject ); - T rolePlayer = roleClass.cast( dataObject ); - setContext( rolePlayer, this ); - return rolePlayer; - } - - private <T> void objectCanPlayRole( Class<T> roleClass, Object dataObject ) - { - if( roleClass.isAssignableFrom( dataObject.getClass() ) ) - { - return; - } - - String className; - if( dataObject instanceof Proxy ) - { - className = Proxy.getInvocationHandler( dataObject ).getClass().getSimpleName(); - } - else - { - className = dataObject.getClass().getSimpleName(); - } - - throw new IllegalArgumentException( - "Object '" + className + "' can't play Role of '" + roleClass.getSimpleName() + "'" ); - } - - /* - * Poor mans Context injection - * */ - private <T> void setContext( T rolePlayer, Context context ) - { - try - { - Method setContextMethod = rolePlayer.getClass().getDeclaredMethod( "setContext", context.getClass() ); - - // Set Context in Role - setContextMethod.invoke( rolePlayer, context ); - } - catch( Exception e ) - { - String c = context.getClass().getSimpleName(); - String r = rolePlayer.getClass().getSimpleName(); - String msg = "Couldn't invoke 'void setContext( " + c + " context);' on " + r + "." + - "\nPlease check the following requirements: " + - "\n1) 'void setContext( " + c + " context);' is declared in " + r + " interface." + - "\n2) " + r + " extends RoleMixin<" + c + ">"; - logger.error( msg, e.getMessage() ); - e.printStackTrace(); - throw new RuntimeException( msg ); - } - } - - // Entity object instantiation - - protected <T, U> T rolePlayer( Class<T> roleClass, Class<U> dataClass, String entityId ) - { - U dataObject = uowf.currentUnitOfWork().get( dataClass, entityId ); - return rolePlayer( roleClass, dataObject ); - } - - protected static <T> T loadEntity( Class<T> roleClass, String entityId ) - { - return uowf.currentUnitOfWork().get( roleClass, entityId ); - } - - public static void prepareContextBaseClass( UnitOfWorkFactory unitOfWorkFactory ) - { - uowf = unitOfWorkFactory; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/dci/RoleMixin.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/dci/RoleMixin.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/dci/RoleMixin.java deleted file mode 100644 index c6e4cc8..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/dci/RoleMixin.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.dci; - -import org.apache.zest.api.injection.scope.Structure; -import org.apache.zest.api.query.QueryBuilderFactory; -import org.apache.zest.api.unitofwork.UnitOfWorkFactory; -import org.apache.zest.api.value.ValueBuilderFactory; - -/** - * Methodful Role implementation base class - * - * Helps "inject" the Context object into the Role Player. - */ -public abstract class RoleMixin<T extends Context> -{ - public T context; - - // Other common role services/methods could be added here... - - @Structure - public UnitOfWorkFactory uowf; - - @Structure - public QueryBuilderFactory qbf; - - @Structure - public ValueBuilderFactory vbf; - - /** - * setContext is called with method invocation in {@link Context#setContext(Object, Context)} - * (therefore "never used" according to IDE) - */ - public void setContext( T context ) - { - this.context = context; - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java deleted file mode 100644 index fdf1e9b..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.model; - -import org.apache.wicket.model.IModel; -import org.apache.zest.api.entity.EntityReference; -import org.apache.zest.api.entity.Identity; -import org.apache.zest.api.injection.scope.Structure; -import org.apache.zest.api.unitofwork.NoSuchEntityException; -import org.apache.zest.api.unitofwork.UnitOfWorkFactory; -import org.apache.zest.api.usecase.Usecase; - -/** - * Javadoc - */ -public class EntityModel<T extends Identity> - extends ReadOnlyModel<T> -{ - private Class<T> entityClass; - private String identity; - private Class<T> dtoClass; - - private transient T dtoComposite; - - @Structure - private UnitOfWorkFactory uowf; - - public EntityModel( Class<T> entityClass, String identity, Class<T> dtoClass ) - { - this.entityClass = entityClass; - this.identity = identity; - this.dtoClass = dtoClass; - } - - public static <T extends Identity> IModel<T> of( Class<T> entityClass, String identity, Class<T> dtoClass ) - { - return new EntityModel<>( entityClass, identity, dtoClass ); - } - - public T getObject() - { - if( dtoComposite == null && identity != null ) - { - dtoComposite = uowf.currentUnitOfWork().toValue( dtoClass, loadEntity() ); - } - return dtoComposite; - } - - public void detach() - { - dtoComposite = null; - } - - private T loadEntity() - { - T entity = module.unitOfWorkFactory().currentUnitOfWork().get( entityClass, identity ); - if( entity == null ) - { - Usecase usecase = module.unitOfWorkFactory().currentUnitOfWork().usecase(); - throw new NoSuchEntityException( EntityReference.parseEntityReference( identity ), entityClass, usecase ); - } - return entity; - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/JSONModel.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/JSONModel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/JSONModel.java deleted file mode 100644 index ced6501..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/JSONModel.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.model; - -import org.apache.zest.api.value.ValueComposite; -import org.apache.zest.api.value.ValueSerializer; - -/** - * Model that can serialize/de-serialize an object to/from a JSON string. - */ -public class JSONModel<T, U extends ValueComposite> - extends ReadOnlyModel<T> -{ - private Class<U> valueCompositeClass; - private String json; - private transient T valueComposite; - - @SuppressWarnings( "unchecked" ) - public JSONModel( T valueComposite, Class<U> valueCompositeClass ) - { - json = module.findService( ValueSerializer.class ).get().serialize( (U) valueComposite );; - this.valueCompositeClass = valueCompositeClass; - } - - @SuppressWarnings( "unchecked" ) - public static <T, U extends ValueComposite> JSONModel<T, U> of( T value ) - { - if( !( value instanceof ValueComposite ) ) - { - throw new RuntimeException( value + " has to be an instance of a ValueComposite." ); - } - - // Get ValueComposite interface - Class<U> valueCompositeClass = (Class<U>) api.valueDescriptorFor( value ).valueType().mainType(); - - return new JSONModel<T, U>( value, valueCompositeClass ); - } - - @SuppressWarnings( "unchecked" ) - public T getObject() - { - if( valueComposite == null && json != null ) - { - // De-serialize - valueComposite = (T) module.newValueFromSerializedState( valueCompositeClass, json ); // Unchecked cast - } - return valueComposite; - } - - public void detach() - { - valueComposite = null; - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/Queries.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/Queries.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/Queries.java deleted file mode 100644 index de576a8..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/Queries.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.model; - -import java.io.Serializable; -import org.apache.zest.api.query.QueryBuilderFactory; -import org.apache.zest.api.unitofwork.UnitOfWorkFactory; - -/** - * Queries base class - */ -public class Queries - implements Serializable // For Wicket (don't remove) -{ - static protected UnitOfWorkFactory uowf; - static protected QueryBuilderFactory qbf; - - public static void prepareQueriesBaseClass( UnitOfWorkFactory unitOfWorkFactory, - QueryBuilderFactory queryBuilderFactory - ) - { - uowf = unitOfWorkFactory; - qbf = queryBuilderFactory; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/QueryModel.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/QueryModel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/QueryModel.java deleted file mode 100644 index b2ee967..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/QueryModel.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.model; - -import java.util.ArrayList; -import java.util.List; -import org.apache.zest.api.entity.EntityComposite; -import org.apache.zest.api.entity.Identity; -import org.apache.zest.api.injection.scope.Structure; -import org.apache.zest.api.query.Query; -import org.apache.zest.api.unitofwork.UnitOfWorkFactory; - -/** - * Callback Wicket model that holds a Zest Query object that can be called when needed to - * retrieve fresh data. - */ -public abstract class QueryModel<T extends Identity> - extends ReadOnlyModel<List<T>> -{ - private Class<T> dtoClass; - private transient List<T> dtoList; - - @Structure - private UnitOfWorkFactory uowf; - - public QueryModel( Class<T> dtoClass ) - { - this.dtoClass = dtoClass; - } - - public List<T> getObject() - { - if( dtoList != null ) - { - return dtoList; - } - - dtoList = new ArrayList<>(); - for( T entity : getQuery() ) - { - dtoList.add( getValue( entity ) ); - } - - return dtoList; - } - - // Callback to retrieve the (unserializable) Zest Query object - public abstract Query<T> getQuery(); - - public T getValue( T entity ) - { - return uowf.currentUnitOfWork().toValue( dtoClass, entity ); - } - - public void detach() - { - dtoList = null; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/ReadOnlyModel.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/ReadOnlyModel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/ReadOnlyModel.java deleted file mode 100644 index 34593fb..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/ReadOnlyModel.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.model; - -import org.apache.wicket.model.IModel; -import org.apache.zest.api.ZestAPI; -import org.apache.zest.api.structure.Module; - -/** - * Abstract base model for Wicket model objects taking Zest objects. - */ -public abstract class ReadOnlyModel<T> - implements IModel<T> -{ - private static final long serialVersionUID = 1L; - - static protected ZestAPI api; - static protected Module module; - - /** - * This default implementation of setObject unconditionally throws an - * UnsupportedOperationException. Since the method is final, any subclass is effectively a - * read-only model. - * - * @param object The object to set into the model - * - * @throws UnsupportedOperationException - */ - public final void setObject( final T object ) - { - throw new UnsupportedOperationException( "Model " + getClass() + - " does not support setObject(Object)" ); - } - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder( "Model:classname=[" ); - sb.append( getClass().getName() ).append( "]" ); - return sb.toString(); - } - - public static void prepareModelBaseClass( Module m, - ZestAPI api - ) - { - module = m; - ReadOnlyModel.api = api; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/color/CorrectColor.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/color/CorrectColor.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/color/CorrectColor.java deleted file mode 100644 index 88c5880..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/color/CorrectColor.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.wicket.color; - -import org.apache.wicket.AttributeModifier; - -/** - * Javadoc - */ -public class CorrectColor extends AttributeModifier -{ - public CorrectColor( Boolean condition ) - { - super( "class", condition ? "correctColor" : "VA_REMOVE" ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/color/ErrorColor.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/color/ErrorColor.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/color/ErrorColor.java deleted file mode 100644 index 84306ae..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/color/ErrorColor.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.wicket.color; - -import org.apache.wicket.AttributeModifier; - -/** - * Javadoc - */ -public class ErrorColor - extends AttributeModifier -{ - - public ErrorColor( Boolean condition ) - { - super( "class", condition ? "errorColor" : "VA_REMOVE" ); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/AbstractForm.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/AbstractForm.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/AbstractForm.java deleted file mode 100644 index 5dcaea3..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/AbstractForm.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.wicket.form; - -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.markup.html.form.Button; -import org.apache.wicket.markup.html.form.CheckBox; -import org.apache.wicket.markup.html.form.FormComponent; -import org.apache.wicket.markup.html.form.RadioChoice; -import org.apache.wicket.markup.html.form.StatelessForm; -import org.apache.wicket.util.visit.IVisit; -import org.apache.wicket.util.visit.IVisitor; - -/** - * - */ -//public abstract class AbstractForm<T> extends Form<T> -public abstract class AbstractForm<T> extends StatelessForm<T> -{ - public AbstractForm( String id ) - { - super( id ); - } - - public AbstractForm() - { - super( "form" ); - } - - public void focusFirstError( final AjaxRequestTarget target ) - { - visitFormComponents( new IVisitor<FormComponent<?>, Void>() - { - public void component( FormComponent<?> fc, IVisit<Void> visit ) - { - if( isOtherComponent( fc ) || fc.isValid() ) - { - return; - } - - target.focusComponent( fc ); - visit.stop(); - } - } ); - } - - private boolean isOtherComponent( FormComponent<?> fc ) - { - return fc instanceof Button || fc instanceof CheckBox || fc instanceof RadioChoice; - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java deleted file mode 100644 index 0237052..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.wicket.form; - -import com.google.code.joliratools.StatelessAjaxEventBehavior; -import java.time.LocalDate; -import java.time.LocalTime; -import java.time.ZoneOffset; -import java.time.format.DateTimeFormatter; -import java.util.Map; -import org.apache.wicket.Component; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.datetime.DateConverter; -import org.apache.wicket.datetime.PatternDateConverter; -import org.apache.wicket.datetime.markup.html.form.DateTextField; -import org.apache.wicket.devutils.stateless.StatelessComponent; -import org.apache.wicket.extensions.yui.calendar.DatePicker; -import org.apache.wicket.markup.html.IHeaderResponse; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.request.mapper.parameter.PageParameters; -import org.apache.wicket.validation.validator.DateValidator; - -import static java.util.Date.from; - -//import org.wicketstuff.stateless.StatelessAjaxEventBehavior; - -/** - * {@link DateTextField} with a {@link DatePicker}. - */ -@StatelessComponent -public class DateTextFieldWithPicker extends DateTextField -{ - DatePicker datePicker; - - // Configurable widget options - private LocalDate earliestDate; - private LocalDate selectedDate; - - private final static DateTimeFormatter YUI_DATE_FORMAT = DateTimeFormatter.ofPattern( "MM/dd/yyyy" ); - - public DateTextFieldWithPicker( String id, String label, Component model ) - { - this( id, label, new PropertyModel<>( model, id ), new PatternDateConverter( "yyyy-MM-dd", true ) ); - } - - public DateTextFieldWithPicker( String id, String label, IModel<java.util.Date> model, DateConverter converter ) - { - super( id, model, converter ); - - // Make the text field reachable by Ajax requests - setOutputMarkupId( true ); - - // Set required as default - setRequired( true ); - - // Add Date Picker with callback configuration - add( newDatePicker().setShowOnFieldClick( true ) ); - - setNonEmptyLabel( label ); - - // Show calendar if tabbing into the text field (weird it isn't default) - add( new StatelessAjaxEventBehavior( "onfocus" ) - { - @Override - protected void onEvent( AjaxRequestTarget target ) - { - String componentId = getComponent().getMarkupId(); - String widgetId = componentId + "DpJs"; - target.appendJavaScript( - "Wicket.DateTime.showCalendar(" + - "YAHOO.wicket['" + widgetId + "'], " + - "document.getElementById('" + componentId + "').value, " + - "'yyyy-MM-dd');" - ); - } - - @Override - protected PageParameters getPageParameters() - { - return null; - } - } ); - -// add( new StatelessAjaxEventBehavior( "onBlur" ) -// { -// @Override -// protected void onEvent( AjaxRequestTarget target ) -// { -// String componentId = getComponent().getMarkupId(); -// String widgetId = componentId + "DpJs"; -// target.appendJavaScript( -// "Wicket.DateTime.showCalendar(" + -// "YAHOO.wicket['" + widgetId + "'], " + -// "document.getElementById('" + componentId + "').value, " + -// "'yyyy-MM-dd');" + -// "YAHOO.wicket['" + widgetId + "'].hide();" ); -// } -// -// @Override -// protected PageParameters getPageParameters() -// { -// return null; -// } -// } ); - } - - private void setNonEmptyLabel( String label ) - { - if( label == null ) - { - return; - } - - if( label.isEmpty() ) - { - throw new IllegalArgumentException( "Can't set an empty label on the drop down selector." ); - } - - setLabel( Model.of( label ) ); - } - - /** - * The DatePicker that gets added to the DateTextField component. Users may override this method - * with a DatePicker of their choice. - * - * @return a new {@link DatePicker} instance - */ - protected DatePicker newDatePicker() - { - return new DatePicker() - { - private static final long serialVersionUID = 1L; - - @Override - protected void configure( final Map<String, Object> widgetProperties, - final IHeaderResponse response, final Map<String, Object> initVariables - ) - { - super.configure( widgetProperties, response, initVariables ); - - DateTextFieldWithPicker.this.configure( widgetProperties ); - } - }; - } - - /** - * Gives overriding classes the option of adding (or even changing/ removing) configuration - * properties for the javascript widget. See <a - * href="http://developer.yahoo.com/yui/calendar/">the widget's documentation</a> for the - * available options. If you want to override/ remove properties, you should call - * super.configure(properties) first. If you don't call that, be aware that you will have to - * call {@literal #localize(Map)} manually if you like localized strings to be added. - * - * @param widgetProperties the current widget properties - */ - protected void configure( Map<String, Object> widgetProperties ) - { - // Set various YUI calendar options - add more if necessary - widgetProperties.put( "mindate", getEarliestDateStr() ); - widgetProperties.put( "selected", getSelectedDateStr() ); - } - - public DateTextFieldWithPicker earliestDate( LocalDate newEarliestDate ) - { - if( selectedDate != null && newEarliestDate.isAfter( selectedDate ) ) - { - throw new IllegalArgumentException( "Earliest date can't be before selected day." ); - } - - earliestDate = newEarliestDate; - - // Input field validation - date should be _after_ minimumDate (not the same) - LocalDate minimumDate = newEarliestDate.minusDays( 1 ); - add( DateValidator.minimum( from( minimumDate.atTime( LocalTime.now() ).toInstant( ZoneOffset.UTC ) ) ) ); - return this; - } - - // Add latestDate(..) + other configuration options if needed.. - - public DateTextFieldWithPicker selectedDate( LocalDate newSelectedDate ) - { - if( earliestDate != null && newSelectedDate.isBefore( earliestDate ) ) - { - throw new IllegalArgumentException( "Selected date can't be before earliest day." ); - } - - selectedDate = newSelectedDate; - - return this; - } - - private String getSelectedDateStr() - { - if( selectedDate != null ) - { - return YUI_DATE_FORMAT.format( selectedDate ); - } - - // Select today or earliest date (if later) as default - return earliestDate == null ? - YUI_DATE_FORMAT.format( LocalDate.now() ) : - YUI_DATE_FORMAT.format( earliestDate ); - } - - private String getEarliestDateStr() - { - return earliestDate == null ? "" : YUI_DATE_FORMAT.format( earliestDate ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/SelectorInForm.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/SelectorInForm.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/SelectorInForm.java deleted file mode 100644 index 8b9b187..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/SelectorInForm.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.wicket.form; - -import java.util.List; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.model.util.ListModel; - -/** - * Drop down list that resolves properties against a form - */ -public class SelectorInForm extends DropDownChoice<String> -{ - PropertyModel<String> disablingPropertyModel; - String disablingValue = ""; - - public SelectorInForm( String property, String label, List<String> choices, Form form ) - { - super( property + "Selector", new PropertyModel<String>( form, property ), new ListModel<String>( choices ) ); - setNonEmptyLabel( label ); - setOutputMarkupId( true ); - } - - public SelectorInForm( String property, String label, List<String> choices, Form form, String disablingProperty ) - { - super( property + "Selector", new PropertyModel<String>( form, property ), new ListModel<String>( choices ) ); - disablingPropertyModel = new PropertyModel<String>( form, disablingProperty ); - setNonEmptyLabel( label ); - setOutputMarkupId( true ); - } - - private void setNonEmptyLabel( String label ) - { - if( label == null ) - { - return; - } - - setLabel( Model.of( label ) ); - } - - @Override - protected boolean isDisabled( final String currentValue, int index, String selected ) - { - if( disablingPropertyModel != null ) - { - disablingValue = disablingPropertyModel.getObject(); - } - - return currentValue.equals( disablingValue ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/link/LinkPanel.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/link/LinkPanel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/link/LinkPanel.java deleted file mode 100644 index 14766a0..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/link/LinkPanel.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.wicket.link; - -import org.apache.wicket.Page; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.link.BookmarkablePageLink; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.request.mapper.parameter.PageParameters; - -/** - * Link panel for displaying a bookmarkable link - */ -public class LinkPanel extends Panel -{ - public <T extends Page> LinkPanel( String id, Class<T> pageClass, String rowId ) - { - this( id, pageClass, rowId, rowId ); - } - - public <T extends Page> LinkPanel( String id, Class<T> pageClass, String rowId, String label ) - { - super( id ); - - PageParameters pageParameters = new PageParameters().set( 0, rowId ); - BookmarkablePageLink<Void> link = new BookmarkablePageLink<Void>( "link", pageClass, pageParameters ); - link.add( new Label( "label", label ) ); - add( link ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/page/BaseWebPage.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/page/BaseWebPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/page/BaseWebPage.java deleted file mode 100644 index 0312915..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/page/BaseWebPage.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.zest.sample.dcicargo.sample_a.infrastructure.wicket.page; - -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.request.mapper.parameter.PageParameters; -import org.apache.zest.api.composite.TransientBuilderFactory; -import org.apache.zest.api.composite.TransientComposite; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Generic Wicket base page - * - * Convenience access to common resources - */ -public class BaseWebPage extends WebPage -{ - public Logger logger = LoggerFactory.getLogger( getClass() ); - - static protected TransientBuilderFactory tbf; - - public BaseWebPage( PageParameters pageParameters ) - { - super( pageParameters ); - } - - public BaseWebPage() - { - } - - public static <T extends TransientComposite> T query( Class<T> queryClass ) - { - return tbf.newTransient( queryClass ); - } - - public static void prepareBaseWebPageClass( TransientBuilderFactory transientBuilderFactory ) - { - tbf = transientBuilderFactory; - } -} \ No newline at end of file
