repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
pextralabs/scene-platform
situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/events/SituationEvent.java // public interface SituationEvent { // // public long getTimestamp(); // public Situation getSituation(); // // }
import br.ufes.inf.lprm.situation.model.events.SituationEvent; import java.util.List;
package br.ufes.inf.lprm.situation.model; public interface Situation { public long getUID();
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/events/SituationEvent.java // public interface SituationEvent { // // public long getTimestamp(); // public Situation getSituation(); // // } // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java import br.ufes.inf.lprm.situation.model.events.SituationEvent; import java.util.List; package br.ufes.inf.lprm.situation.model; public interface Situation { public long getUID();
public SituationEvent getActivation();
pextralabs/scene-platform
scene-core/src/main/java/br/ufes/inf/lprm/scene/model/SituationType.java
// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/events/Activation.java // public class Activation extends SituationEvent { // // private static final long serialVersionUID = -8574595668587040347L; // // public Activation(long timestamp) { // super(timestamp); // } // // public String toString() { // DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy MM dd HH:mm:ss"); // DateTime activation = new DateTime(this.getTimestamp()); // StringBuilder str = new StringBuilder(); // str.append("\tActivation timestamp: "); // str.append(activation.toString(fmt)); // str.append("."); // return str.toString(); // } // // } // // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/util/SituationCast.java // @SuppressWarnings("serial") // public class SituationCast extends HashMap<String, Object> { // // private int hash = 17; // // public SituationCast(Activation activation, SituationType type) throws Exception { // // int counter; // String roleLabel; // Object obj; // RuleImpl rule = activation.getRule(); // //List<Part> parts = type.getParts(); // // for(Part p: type.getParts()) { // put(p.getLabel(), activation.getDeclarationValue(p.getLabel()), p.isKey()); // } // // for(Snapshot s: type.getSnapshots()) { // put(s.getLabel(), activation.getDeclarationValue(s.getLabel()), false); // // } // } // // // /*public SituationCast(Situation sit) { // List<Field> fields = SituationUtils.getSituationRoleFields(sit.getClass()); // for(Field field: fields) { // try { // this.put(field.getName(), field.get(sit)); // } catch (IllegalArgumentException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // }*/ // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } // else { // if ( !(obj instanceof SituationCast) ) { // return false; // } // else { // return this.hashCode() == obj.hashCode(); // // } // } // } // // public Object put(String key, Object value, boolean hash) { // // if (hash) { // this.hash = this.hash + (key.hashCode() + value.getClass().hashCode() + value.hashCode()); // this.hash = 31*this.hash + key.hashCode(); // this.hash = 31*this.hash + value.getClass().hashCode(); // this.hash = 31*this.hash + value.hashCode(); // } // return super.put(key, value); // } // // @Override // public int hashCode() { // return hash; // } // // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Part.java // public interface Part extends Bind { // public boolean isKey(); // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Snapshot.java // public interface Snapshot extends Bind { // // public SnapshotPolicy getPolicy(); // // }
import br.ufes.inf.lprm.scene.model.events.Activation; import br.ufes.inf.lprm.scene.util.SituationCast; import br.ufes.inf.lprm.situation.model.bindings.Part; import br.ufes.inf.lprm.situation.model.bindings.Snapshot; import java.lang.reflect.Field; import java.util.*;
package br.ufes.inf.lprm.scene.model; public class SituationType implements br.ufes.inf.lprm.situation.model.SituationType { private Class clazz;
// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/events/Activation.java // public class Activation extends SituationEvent { // // private static final long serialVersionUID = -8574595668587040347L; // // public Activation(long timestamp) { // super(timestamp); // } // // public String toString() { // DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy MM dd HH:mm:ss"); // DateTime activation = new DateTime(this.getTimestamp()); // StringBuilder str = new StringBuilder(); // str.append("\tActivation timestamp: "); // str.append(activation.toString(fmt)); // str.append("."); // return str.toString(); // } // // } // // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/util/SituationCast.java // @SuppressWarnings("serial") // public class SituationCast extends HashMap<String, Object> { // // private int hash = 17; // // public SituationCast(Activation activation, SituationType type) throws Exception { // // int counter; // String roleLabel; // Object obj; // RuleImpl rule = activation.getRule(); // //List<Part> parts = type.getParts(); // // for(Part p: type.getParts()) { // put(p.getLabel(), activation.getDeclarationValue(p.getLabel()), p.isKey()); // } // // for(Snapshot s: type.getSnapshots()) { // put(s.getLabel(), activation.getDeclarationValue(s.getLabel()), false); // // } // } // // // /*public SituationCast(Situation sit) { // List<Field> fields = SituationUtils.getSituationRoleFields(sit.getClass()); // for(Field field: fields) { // try { // this.put(field.getName(), field.get(sit)); // } catch (IllegalArgumentException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // }*/ // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } // else { // if ( !(obj instanceof SituationCast) ) { // return false; // } // else { // return this.hashCode() == obj.hashCode(); // // } // } // } // // public Object put(String key, Object value, boolean hash) { // // if (hash) { // this.hash = this.hash + (key.hashCode() + value.getClass().hashCode() + value.hashCode()); // this.hash = 31*this.hash + key.hashCode(); // this.hash = 31*this.hash + value.getClass().hashCode(); // this.hash = 31*this.hash + value.hashCode(); // } // return super.put(key, value); // } // // @Override // public int hashCode() { // return hash; // } // // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Part.java // public interface Part extends Bind { // public boolean isKey(); // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Snapshot.java // public interface Snapshot extends Bind { // // public SnapshotPolicy getPolicy(); // // } // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/SituationType.java import br.ufes.inf.lprm.scene.model.events.Activation; import br.ufes.inf.lprm.scene.util.SituationCast; import br.ufes.inf.lprm.situation.model.bindings.Part; import br.ufes.inf.lprm.situation.model.bindings.Snapshot; import java.lang.reflect.Field; import java.util.*; package br.ufes.inf.lprm.scene.model; public class SituationType implements br.ufes.inf.lprm.situation.model.SituationType { private Class clazz;
private List<Part> parts;
pextralabs/scene-platform
scene-core/src/main/java/br/ufes/inf/lprm/scene/model/SituationType.java
// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/events/Activation.java // public class Activation extends SituationEvent { // // private static final long serialVersionUID = -8574595668587040347L; // // public Activation(long timestamp) { // super(timestamp); // } // // public String toString() { // DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy MM dd HH:mm:ss"); // DateTime activation = new DateTime(this.getTimestamp()); // StringBuilder str = new StringBuilder(); // str.append("\tActivation timestamp: "); // str.append(activation.toString(fmt)); // str.append("."); // return str.toString(); // } // // } // // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/util/SituationCast.java // @SuppressWarnings("serial") // public class SituationCast extends HashMap<String, Object> { // // private int hash = 17; // // public SituationCast(Activation activation, SituationType type) throws Exception { // // int counter; // String roleLabel; // Object obj; // RuleImpl rule = activation.getRule(); // //List<Part> parts = type.getParts(); // // for(Part p: type.getParts()) { // put(p.getLabel(), activation.getDeclarationValue(p.getLabel()), p.isKey()); // } // // for(Snapshot s: type.getSnapshots()) { // put(s.getLabel(), activation.getDeclarationValue(s.getLabel()), false); // // } // } // // // /*public SituationCast(Situation sit) { // List<Field> fields = SituationUtils.getSituationRoleFields(sit.getClass()); // for(Field field: fields) { // try { // this.put(field.getName(), field.get(sit)); // } catch (IllegalArgumentException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // }*/ // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } // else { // if ( !(obj instanceof SituationCast) ) { // return false; // } // else { // return this.hashCode() == obj.hashCode(); // // } // } // } // // public Object put(String key, Object value, boolean hash) { // // if (hash) { // this.hash = this.hash + (key.hashCode() + value.getClass().hashCode() + value.hashCode()); // this.hash = 31*this.hash + key.hashCode(); // this.hash = 31*this.hash + value.getClass().hashCode(); // this.hash = 31*this.hash + value.hashCode(); // } // return super.put(key, value); // } // // @Override // public int hashCode() { // return hash; // } // // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Part.java // public interface Part extends Bind { // public boolean isKey(); // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Snapshot.java // public interface Snapshot extends Bind { // // public SnapshotPolicy getPolicy(); // // }
import br.ufes.inf.lprm.scene.model.events.Activation; import br.ufes.inf.lprm.scene.util.SituationCast; import br.ufes.inf.lprm.situation.model.bindings.Part; import br.ufes.inf.lprm.situation.model.bindings.Snapshot; import java.lang.reflect.Field; import java.util.*;
package br.ufes.inf.lprm.scene.model; public class SituationType implements br.ufes.inf.lprm.situation.model.SituationType { private Class clazz; private List<Part> parts;
// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/events/Activation.java // public class Activation extends SituationEvent { // // private static final long serialVersionUID = -8574595668587040347L; // // public Activation(long timestamp) { // super(timestamp); // } // // public String toString() { // DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy MM dd HH:mm:ss"); // DateTime activation = new DateTime(this.getTimestamp()); // StringBuilder str = new StringBuilder(); // str.append("\tActivation timestamp: "); // str.append(activation.toString(fmt)); // str.append("."); // return str.toString(); // } // // } // // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/util/SituationCast.java // @SuppressWarnings("serial") // public class SituationCast extends HashMap<String, Object> { // // private int hash = 17; // // public SituationCast(Activation activation, SituationType type) throws Exception { // // int counter; // String roleLabel; // Object obj; // RuleImpl rule = activation.getRule(); // //List<Part> parts = type.getParts(); // // for(Part p: type.getParts()) { // put(p.getLabel(), activation.getDeclarationValue(p.getLabel()), p.isKey()); // } // // for(Snapshot s: type.getSnapshots()) { // put(s.getLabel(), activation.getDeclarationValue(s.getLabel()), false); // // } // } // // // /*public SituationCast(Situation sit) { // List<Field> fields = SituationUtils.getSituationRoleFields(sit.getClass()); // for(Field field: fields) { // try { // this.put(field.getName(), field.get(sit)); // } catch (IllegalArgumentException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // }*/ // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } // else { // if ( !(obj instanceof SituationCast) ) { // return false; // } // else { // return this.hashCode() == obj.hashCode(); // // } // } // } // // public Object put(String key, Object value, boolean hash) { // // if (hash) { // this.hash = this.hash + (key.hashCode() + value.getClass().hashCode() + value.hashCode()); // this.hash = 31*this.hash + key.hashCode(); // this.hash = 31*this.hash + value.getClass().hashCode(); // this.hash = 31*this.hash + value.hashCode(); // } // return super.put(key, value); // } // // @Override // public int hashCode() { // return hash; // } // // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Part.java // public interface Part extends Bind { // public boolean isKey(); // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Snapshot.java // public interface Snapshot extends Bind { // // public SnapshotPolicy getPolicy(); // // } // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/SituationType.java import br.ufes.inf.lprm.scene.model.events.Activation; import br.ufes.inf.lprm.scene.util.SituationCast; import br.ufes.inf.lprm.situation.model.bindings.Part; import br.ufes.inf.lprm.situation.model.bindings.Snapshot; import java.lang.reflect.Field; import java.util.*; package br.ufes.inf.lprm.scene.model; public class SituationType implements br.ufes.inf.lprm.situation.model.SituationType { private Class clazz; private List<Part> parts;
private List<Snapshot> snapshots;
pextralabs/scene-platform
scene-core/src/main/java/br/ufes/inf/lprm/scene/model/SituationType.java
// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/events/Activation.java // public class Activation extends SituationEvent { // // private static final long serialVersionUID = -8574595668587040347L; // // public Activation(long timestamp) { // super(timestamp); // } // // public String toString() { // DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy MM dd HH:mm:ss"); // DateTime activation = new DateTime(this.getTimestamp()); // StringBuilder str = new StringBuilder(); // str.append("\tActivation timestamp: "); // str.append(activation.toString(fmt)); // str.append("."); // return str.toString(); // } // // } // // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/util/SituationCast.java // @SuppressWarnings("serial") // public class SituationCast extends HashMap<String, Object> { // // private int hash = 17; // // public SituationCast(Activation activation, SituationType type) throws Exception { // // int counter; // String roleLabel; // Object obj; // RuleImpl rule = activation.getRule(); // //List<Part> parts = type.getParts(); // // for(Part p: type.getParts()) { // put(p.getLabel(), activation.getDeclarationValue(p.getLabel()), p.isKey()); // } // // for(Snapshot s: type.getSnapshots()) { // put(s.getLabel(), activation.getDeclarationValue(s.getLabel()), false); // // } // } // // // /*public SituationCast(Situation sit) { // List<Field> fields = SituationUtils.getSituationRoleFields(sit.getClass()); // for(Field field: fields) { // try { // this.put(field.getName(), field.get(sit)); // } catch (IllegalArgumentException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // }*/ // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } // else { // if ( !(obj instanceof SituationCast) ) { // return false; // } // else { // return this.hashCode() == obj.hashCode(); // // } // } // } // // public Object put(String key, Object value, boolean hash) { // // if (hash) { // this.hash = this.hash + (key.hashCode() + value.getClass().hashCode() + value.hashCode()); // this.hash = 31*this.hash + key.hashCode(); // this.hash = 31*this.hash + value.getClass().hashCode(); // this.hash = 31*this.hash + value.hashCode(); // } // return super.put(key, value); // } // // @Override // public int hashCode() { // return hash; // } // // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Part.java // public interface Part extends Bind { // public boolean isKey(); // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Snapshot.java // public interface Snapshot extends Bind { // // public SnapshotPolicy getPolicy(); // // }
import br.ufes.inf.lprm.scene.model.events.Activation; import br.ufes.inf.lprm.scene.util.SituationCast; import br.ufes.inf.lprm.situation.model.bindings.Part; import br.ufes.inf.lprm.situation.model.bindings.Snapshot; import java.lang.reflect.Field; import java.util.*;
} mappedSnapshots = new HashMap<String, Snapshot>(); for (Snapshot snapshot: this.snapshots) { mappedSnapshots.put(snapshot.getLabel(), snapshot); } } @Override public String getName() { return clazz.getName(); } public Class getTypeClass() { return clazz; } @Override public List<Part> getParts() { return parts; } @Override public List<Snapshot> getSnapshots() { return snapshots; } public Part getPart(String label) { return mappedParts.get(label); }
// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/events/Activation.java // public class Activation extends SituationEvent { // // private static final long serialVersionUID = -8574595668587040347L; // // public Activation(long timestamp) { // super(timestamp); // } // // public String toString() { // DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy MM dd HH:mm:ss"); // DateTime activation = new DateTime(this.getTimestamp()); // StringBuilder str = new StringBuilder(); // str.append("\tActivation timestamp: "); // str.append(activation.toString(fmt)); // str.append("."); // return str.toString(); // } // // } // // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/util/SituationCast.java // @SuppressWarnings("serial") // public class SituationCast extends HashMap<String, Object> { // // private int hash = 17; // // public SituationCast(Activation activation, SituationType type) throws Exception { // // int counter; // String roleLabel; // Object obj; // RuleImpl rule = activation.getRule(); // //List<Part> parts = type.getParts(); // // for(Part p: type.getParts()) { // put(p.getLabel(), activation.getDeclarationValue(p.getLabel()), p.isKey()); // } // // for(Snapshot s: type.getSnapshots()) { // put(s.getLabel(), activation.getDeclarationValue(s.getLabel()), false); // // } // } // // // /*public SituationCast(Situation sit) { // List<Field> fields = SituationUtils.getSituationRoleFields(sit.getClass()); // for(Field field: fields) { // try { // this.put(field.getName(), field.get(sit)); // } catch (IllegalArgumentException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // }*/ // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } // else { // if ( !(obj instanceof SituationCast) ) { // return false; // } // else { // return this.hashCode() == obj.hashCode(); // // } // } // } // // public Object put(String key, Object value, boolean hash) { // // if (hash) { // this.hash = this.hash + (key.hashCode() + value.getClass().hashCode() + value.hashCode()); // this.hash = 31*this.hash + key.hashCode(); // this.hash = 31*this.hash + value.getClass().hashCode(); // this.hash = 31*this.hash + value.hashCode(); // } // return super.put(key, value); // } // // @Override // public int hashCode() { // return hash; // } // // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Part.java // public interface Part extends Bind { // public boolean isKey(); // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Snapshot.java // public interface Snapshot extends Bind { // // public SnapshotPolicy getPolicy(); // // } // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/SituationType.java import br.ufes.inf.lprm.scene.model.events.Activation; import br.ufes.inf.lprm.scene.util.SituationCast; import br.ufes.inf.lprm.situation.model.bindings.Part; import br.ufes.inf.lprm.situation.model.bindings.Snapshot; import java.lang.reflect.Field; import java.util.*; } mappedSnapshots = new HashMap<String, Snapshot>(); for (Snapshot snapshot: this.snapshots) { mappedSnapshots.put(snapshot.getLabel(), snapshot); } } @Override public String getName() { return clazz.getName(); } public Class getTypeClass() { return clazz; } @Override public List<Part> getParts() { return parts; } @Override public List<Snapshot> getSnapshots() { return snapshots; } public Part getPart(String label) { return mappedParts.get(label); }
public Situation newInstance(Activation activation, SituationCast cast) {
pextralabs/scene-platform
scene-core/src/main/java/br/ufes/inf/lprm/scene/model/SituationType.java
// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/events/Activation.java // public class Activation extends SituationEvent { // // private static final long serialVersionUID = -8574595668587040347L; // // public Activation(long timestamp) { // super(timestamp); // } // // public String toString() { // DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy MM dd HH:mm:ss"); // DateTime activation = new DateTime(this.getTimestamp()); // StringBuilder str = new StringBuilder(); // str.append("\tActivation timestamp: "); // str.append(activation.toString(fmt)); // str.append("."); // return str.toString(); // } // // } // // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/util/SituationCast.java // @SuppressWarnings("serial") // public class SituationCast extends HashMap<String, Object> { // // private int hash = 17; // // public SituationCast(Activation activation, SituationType type) throws Exception { // // int counter; // String roleLabel; // Object obj; // RuleImpl rule = activation.getRule(); // //List<Part> parts = type.getParts(); // // for(Part p: type.getParts()) { // put(p.getLabel(), activation.getDeclarationValue(p.getLabel()), p.isKey()); // } // // for(Snapshot s: type.getSnapshots()) { // put(s.getLabel(), activation.getDeclarationValue(s.getLabel()), false); // // } // } // // // /*public SituationCast(Situation sit) { // List<Field> fields = SituationUtils.getSituationRoleFields(sit.getClass()); // for(Field field: fields) { // try { // this.put(field.getName(), field.get(sit)); // } catch (IllegalArgumentException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // }*/ // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } // else { // if ( !(obj instanceof SituationCast) ) { // return false; // } // else { // return this.hashCode() == obj.hashCode(); // // } // } // } // // public Object put(String key, Object value, boolean hash) { // // if (hash) { // this.hash = this.hash + (key.hashCode() + value.getClass().hashCode() + value.hashCode()); // this.hash = 31*this.hash + key.hashCode(); // this.hash = 31*this.hash + value.getClass().hashCode(); // this.hash = 31*this.hash + value.hashCode(); // } // return super.put(key, value); // } // // @Override // public int hashCode() { // return hash; // } // // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Part.java // public interface Part extends Bind { // public boolean isKey(); // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Snapshot.java // public interface Snapshot extends Bind { // // public SnapshotPolicy getPolicy(); // // }
import br.ufes.inf.lprm.scene.model.events.Activation; import br.ufes.inf.lprm.scene.util.SituationCast; import br.ufes.inf.lprm.situation.model.bindings.Part; import br.ufes.inf.lprm.situation.model.bindings.Snapshot; import java.lang.reflect.Field; import java.util.*;
} mappedSnapshots = new HashMap<String, Snapshot>(); for (Snapshot snapshot: this.snapshots) { mappedSnapshots.put(snapshot.getLabel(), snapshot); } } @Override public String getName() { return clazz.getName(); } public Class getTypeClass() { return clazz; } @Override public List<Part> getParts() { return parts; } @Override public List<Snapshot> getSnapshots() { return snapshots; } public Part getPart(String label) { return mappedParts.get(label); }
// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/events/Activation.java // public class Activation extends SituationEvent { // // private static final long serialVersionUID = -8574595668587040347L; // // public Activation(long timestamp) { // super(timestamp); // } // // public String toString() { // DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy MM dd HH:mm:ss"); // DateTime activation = new DateTime(this.getTimestamp()); // StringBuilder str = new StringBuilder(); // str.append("\tActivation timestamp: "); // str.append(activation.toString(fmt)); // str.append("."); // return str.toString(); // } // // } // // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/util/SituationCast.java // @SuppressWarnings("serial") // public class SituationCast extends HashMap<String, Object> { // // private int hash = 17; // // public SituationCast(Activation activation, SituationType type) throws Exception { // // int counter; // String roleLabel; // Object obj; // RuleImpl rule = activation.getRule(); // //List<Part> parts = type.getParts(); // // for(Part p: type.getParts()) { // put(p.getLabel(), activation.getDeclarationValue(p.getLabel()), p.isKey()); // } // // for(Snapshot s: type.getSnapshots()) { // put(s.getLabel(), activation.getDeclarationValue(s.getLabel()), false); // // } // } // // // /*public SituationCast(Situation sit) { // List<Field> fields = SituationUtils.getSituationRoleFields(sit.getClass()); // for(Field field: fields) { // try { // this.put(field.getName(), field.get(sit)); // } catch (IllegalArgumentException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // }*/ // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } // else { // if ( !(obj instanceof SituationCast) ) { // return false; // } // else { // return this.hashCode() == obj.hashCode(); // // } // } // } // // public Object put(String key, Object value, boolean hash) { // // if (hash) { // this.hash = this.hash + (key.hashCode() + value.getClass().hashCode() + value.hashCode()); // this.hash = 31*this.hash + key.hashCode(); // this.hash = 31*this.hash + value.getClass().hashCode(); // this.hash = 31*this.hash + value.hashCode(); // } // return super.put(key, value); // } // // @Override // public int hashCode() { // return hash; // } // // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Part.java // public interface Part extends Bind { // public boolean isKey(); // } // // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/bindings/Snapshot.java // public interface Snapshot extends Bind { // // public SnapshotPolicy getPolicy(); // // } // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/SituationType.java import br.ufes.inf.lprm.scene.model.events.Activation; import br.ufes.inf.lprm.scene.util.SituationCast; import br.ufes.inf.lprm.situation.model.bindings.Part; import br.ufes.inf.lprm.situation.model.bindings.Snapshot; import java.lang.reflect.Field; import java.util.*; } mappedSnapshots = new HashMap<String, Snapshot>(); for (Snapshot snapshot: this.snapshots) { mappedSnapshots.put(snapshot.getLabel(), snapshot); } } @Override public String getName() { return clazz.getName(); } public Class getTypeClass() { return clazz; } @Override public List<Part> getParts() { return parts; } @Override public List<Snapshot> getSnapshots() { return snapshots; } public Part getPart(String label) { return mappedParts.get(label); }
public Situation newInstance(Activation activation, SituationCast cast) {
pextralabs/scene-platform
scene-core/src/main/java/br/ufes/inf/lprm/scene/base/evaluators/implementation/OverlappedByEvaluator.java
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // }
import br.ufes.inf.lprm.situation.model.Situation; import org.drools.core.base.ValueType; import org.drools.core.base.evaluators.OverlappedByEvaluatorDefinition; import org.drools.core.common.EventFactHandle; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.rule.VariableRestriction; import org.drools.core.rule.VariableRestriction.VariableContextEntry; import org.drools.core.spi.FieldValue; import org.drools.core.spi.InternalReadAccessor; import java.lang.reflect.Field;
try { Field minDev = this.getClass().getSuperclass().getDeclaredField("minDev"); minDev.setAccessible(true); this.minDev = minDev.getLong(this); Field maxDev = this.getClass().getSuperclass().getDeclaredField("maxDev"); maxDev.setAccessible(true); this.maxDev = maxDev.getLong(this); } catch (Exception e) { throw new RuntimeException( e.getMessage() ); } } @Override public boolean evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor, InternalFactHandle factHandle, FieldValue value) { throw new RuntimeException( "The 'overlappedby' operator can only be used to compare one event to another, and never to compare to literal constraints." ); } @Override public boolean evaluateCachedRight(InternalWorkingMemory workingMemory, VariableContextEntry context, InternalFactHandle left) { if ( context.rightNull || context.declaration.getExtractor().isNullValue( workingMemory, left.getObject() )) { return false; } long leftStartTS, leftEndTS, rightStartTS, rightEndTS; rightStartTS = ((VariableRestriction.TemporalVariableContextEntry) context).startTS; rightEndTS = ((VariableRestriction.TemporalVariableContextEntry) context).endTS;
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // } // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/base/evaluators/implementation/OverlappedByEvaluator.java import br.ufes.inf.lprm.situation.model.Situation; import org.drools.core.base.ValueType; import org.drools.core.base.evaluators.OverlappedByEvaluatorDefinition; import org.drools.core.common.EventFactHandle; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.rule.VariableRestriction; import org.drools.core.rule.VariableRestriction.VariableContextEntry; import org.drools.core.spi.FieldValue; import org.drools.core.spi.InternalReadAccessor; import java.lang.reflect.Field; try { Field minDev = this.getClass().getSuperclass().getDeclaredField("minDev"); minDev.setAccessible(true); this.minDev = minDev.getLong(this); Field maxDev = this.getClass().getSuperclass().getDeclaredField("maxDev"); maxDev.setAccessible(true); this.maxDev = maxDev.getLong(this); } catch (Exception e) { throw new RuntimeException( e.getMessage() ); } } @Override public boolean evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor, InternalFactHandle factHandle, FieldValue value) { throw new RuntimeException( "The 'overlappedby' operator can only be used to compare one event to another, and never to compare to literal constraints." ); } @Override public boolean evaluateCachedRight(InternalWorkingMemory workingMemory, VariableContextEntry context, InternalFactHandle left) { if ( context.rightNull || context.declaration.getExtractor().isNullValue( workingMemory, left.getObject() )) { return false; } long leftStartTS, leftEndTS, rightStartTS, rightEndTS; rightStartTS = ((VariableRestriction.TemporalVariableContextEntry) context).startTS; rightEndTS = ((VariableRestriction.TemporalVariableContextEntry) context).endTS;
if (left.getObject() instanceof Situation) {
pextralabs/scene-platform
scene-core/src/main/java/br/ufes/inf/lprm/scene/model/Part.java
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // }
import br.ufes.inf.lprm.situation.model.Situation; import java.lang.reflect.Field;
package br.ufes.inf.lprm.scene.model; public class Part implements br.ufes.inf.lprm.situation.model.bindings.Part { private String label; private Field field; private boolean isKey; public Part(String label, Field field, boolean isKey) { this.label = label; this.field = field; this.isKey = isKey; } @Override public String getLabel() { return label; } @Override public boolean isKey() { return isKey; } public Field getField() { return field; }
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // } // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/Part.java import br.ufes.inf.lprm.situation.model.Situation; import java.lang.reflect.Field; package br.ufes.inf.lprm.scene.model; public class Part implements br.ufes.inf.lprm.situation.model.bindings.Part { private String label; private Field field; private boolean isKey; public Part(String label, Field field, boolean isKey) { this.label = label; this.field = field; this.isKey = isKey; } @Override public String getLabel() { return label; } @Override public boolean isKey() { return isKey; } public Field getField() { return field; }
public void set(Situation situation, Object participant) throws IllegalAccessException {
pextralabs/scene-platform
scene-core/src/main/java/br/ufes/inf/lprm/scene/base/evaluators/implementation/BeforeEvaluator.java
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // }
import br.ufes.inf.lprm.situation.model.Situation; import org.drools.core.base.ValueType; import org.drools.core.common.EventFactHandle; import org.drools.core.common.InternalFactHandle;
package br.ufes.inf.lprm.scene.base.evaluators.implementation; /** * Created by hborjaille on 9/7/16. */ public class BeforeEvaluator extends org.drools.core.base.evaluators.BeforeEvaluatorDefinition.BeforeEvaluator { public BeforeEvaluator(ValueType type, boolean isNegated, long[] parameters, String paramText, boolean unwrapLeft, boolean unwrapRight) { super( type, isNegated, parameters, paramText, unwrapLeft, unwrapRight ); } @Override protected long getLeftTimestamp( InternalFactHandle handle ) { Object obj = handle.getObject();
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // } // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/base/evaluators/implementation/BeforeEvaluator.java import br.ufes.inf.lprm.situation.model.Situation; import org.drools.core.base.ValueType; import org.drools.core.common.EventFactHandle; import org.drools.core.common.InternalFactHandle; package br.ufes.inf.lprm.scene.base.evaluators.implementation; /** * Created by hborjaille on 9/7/16. */ public class BeforeEvaluator extends org.drools.core.base.evaluators.BeforeEvaluatorDefinition.BeforeEvaluator { public BeforeEvaluator(ValueType type, boolean isNegated, long[] parameters, String paramText, boolean unwrapLeft, boolean unwrapRight) { super( type, isNegated, parameters, paramText, unwrapLeft, unwrapRight ); } @Override protected long getLeftTimestamp( InternalFactHandle handle ) { Object obj = handle.getObject();
if (obj instanceof Situation) {
pextralabs/scene-platform
scene-core/src/main/java/br/ufes/inf/lprm/scene/base/evaluators/implementation/MeetsEvaluator.java
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // }
import br.ufes.inf.lprm.situation.model.Situation; import org.drools.core.base.ValueType; import org.drools.core.base.evaluators.MeetsEvaluatorDefinition; import org.drools.core.common.EventFactHandle; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.rule.VariableRestriction.VariableContextEntry; import org.drools.core.rule.VariableRestriction.LeftStartRightEndContextEntry; import org.drools.core.spi.FieldValue; import org.drools.core.spi.InternalReadAccessor; import java.lang.reflect.Field;
extractParams(); } private void extractParams() { try { Field finalRange = this.getClass().getSuperclass().getDeclaredField("finalRange"); finalRange.setAccessible(true); this.finalRange = finalRange.getLong(this); } catch (Exception e) { throw new RuntimeException( e.getMessage() ); } } public boolean evaluate(InternalWorkingMemory workingMemory, final InternalReadAccessor extractor, final InternalFactHandle object1, final FieldValue object2) { throw new RuntimeException( "The 'meets' operator can only be used to compare one event or situation event to another, and never to compare to literal constraints." ); } public boolean evaluateCachedRight(InternalWorkingMemory workingMemory, final VariableContextEntry context, final InternalFactHandle left) { if ( context.rightNull || context.declaration.getExtractor().isNullValue( workingMemory, left.getObject() )) { return false; } long leftStartTS;
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // } // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/base/evaluators/implementation/MeetsEvaluator.java import br.ufes.inf.lprm.situation.model.Situation; import org.drools.core.base.ValueType; import org.drools.core.base.evaluators.MeetsEvaluatorDefinition; import org.drools.core.common.EventFactHandle; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.rule.VariableRestriction.VariableContextEntry; import org.drools.core.rule.VariableRestriction.LeftStartRightEndContextEntry; import org.drools.core.spi.FieldValue; import org.drools.core.spi.InternalReadAccessor; import java.lang.reflect.Field; extractParams(); } private void extractParams() { try { Field finalRange = this.getClass().getSuperclass().getDeclaredField("finalRange"); finalRange.setAccessible(true); this.finalRange = finalRange.getLong(this); } catch (Exception e) { throw new RuntimeException( e.getMessage() ); } } public boolean evaluate(InternalWorkingMemory workingMemory, final InternalReadAccessor extractor, final InternalFactHandle object1, final FieldValue object2) { throw new RuntimeException( "The 'meets' operator can only be used to compare one event or situation event to another, and never to compare to literal constraints." ); } public boolean evaluateCachedRight(InternalWorkingMemory workingMemory, final VariableContextEntry context, final InternalFactHandle left) { if ( context.rightNull || context.declaration.getExtractor().isNullValue( workingMemory, left.getObject() )) { return false; } long leftStartTS;
if (left.getObject() instanceof Situation) {
pextralabs/scene-platform
scene-core/src/main/java/br/ufes/inf/lprm/scene/base/evaluators/implementation/OverlapsEvaluator.java
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // }
import br.ufes.inf.lprm.situation.model.Situation; import org.drools.core.base.ValueType; import org.drools.core.base.evaluators.OverlapsEvaluatorDefinition; import org.drools.core.common.EventFactHandle; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.rule.VariableRestriction; import org.drools.core.rule.VariableRestriction.VariableContextEntry; import org.drools.core.spi.FieldValue; import org.drools.core.spi.InternalReadAccessor; import java.lang.reflect.Field;
minDev.setAccessible(true); this.minDev = minDev.getLong(this); Field maxDev = this.getClass().getSuperclass().getDeclaredField("maxDev"); maxDev.setAccessible(true); this.maxDev = maxDev.getLong(this); } catch (Exception e) { throw new RuntimeException( e.getMessage() ); } } @Override public boolean evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor, InternalFactHandle factHandle, FieldValue value) { throw new RuntimeException( "The 'overlaps' operator can only be used to compare one event to another, and never to compare to literal constraints." ); } @Override public boolean evaluateCachedRight(InternalWorkingMemory workingMemory, VariableContextEntry context, InternalFactHandle left) { if ( context.rightNull || context.declaration.getExtractor().isNullValue( workingMemory, left.getObject() )) { return false; } long leftStartTS, leftEndTS, rightStartTS, rightEndTS; rightStartTS = ((VariableRestriction.TemporalVariableContextEntry) context).startTS; rightEndTS = ((VariableRestriction.TemporalVariableContextEntry) context).endTS;
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // } // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/base/evaluators/implementation/OverlapsEvaluator.java import br.ufes.inf.lprm.situation.model.Situation; import org.drools.core.base.ValueType; import org.drools.core.base.evaluators.OverlapsEvaluatorDefinition; import org.drools.core.common.EventFactHandle; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.rule.VariableRestriction; import org.drools.core.rule.VariableRestriction.VariableContextEntry; import org.drools.core.spi.FieldValue; import org.drools.core.spi.InternalReadAccessor; import java.lang.reflect.Field; minDev.setAccessible(true); this.minDev = minDev.getLong(this); Field maxDev = this.getClass().getSuperclass().getDeclaredField("maxDev"); maxDev.setAccessible(true); this.maxDev = maxDev.getLong(this); } catch (Exception e) { throw new RuntimeException( e.getMessage() ); } } @Override public boolean evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor, InternalFactHandle factHandle, FieldValue value) { throw new RuntimeException( "The 'overlaps' operator can only be used to compare one event to another, and never to compare to literal constraints." ); } @Override public boolean evaluateCachedRight(InternalWorkingMemory workingMemory, VariableContextEntry context, InternalFactHandle left) { if ( context.rightNull || context.declaration.getExtractor().isNullValue( workingMemory, left.getObject() )) { return false; } long leftStartTS, leftEndTS, rightStartTS, rightEndTS; rightStartTS = ((VariableRestriction.TemporalVariableContextEntry) context).startTS; rightEndTS = ((VariableRestriction.TemporalVariableContextEntry) context).endTS;
if (left.getObject() instanceof Situation) {
pextralabs/scene-platform
situation-model/src/main/java/br/ufes/inf/lprm/situation/model/events/SituationEvent.java
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // }
import java.io.Serializable; import br.ufes.inf.lprm.situation.model.Situation;
package br.ufes.inf.lprm.situation.model.events; public interface SituationEvent { public long getTimestamp();
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // } // Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/events/SituationEvent.java import java.io.Serializable; import br.ufes.inf.lprm.situation.model.Situation; package br.ufes.inf.lprm.situation.model.events; public interface SituationEvent { public long getTimestamp();
public Situation getSituation();
pextralabs/scene-platform
scene-core/src/main/java/br/ufes/inf/lprm/scene/base/evaluators/implementation/AfterEvaluator.java
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // }
import br.ufes.inf.lprm.situation.model.Situation; import org.drools.core.base.ValueType; import org.drools.core.base.evaluators.AfterEvaluatorDefinition; import org.drools.core.common.EventFactHandle; import org.drools.core.common.InternalFactHandle;
package br.ufes.inf.lprm.scene.base.evaluators.implementation; public class AfterEvaluator extends AfterEvaluatorDefinition.AfterEvaluator { public AfterEvaluator( final ValueType type, final boolean isNegated, final long[] parameters, final String paramText, final boolean unwrapLeft, final boolean unwrapRight ) { super( type, isNegated, parameters, paramText, unwrapLeft, unwrapRight ); } @Override protected long getLeftTimestamp( InternalFactHandle handle ) { Object obj = handle.getObject();
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // } // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/base/evaluators/implementation/AfterEvaluator.java import br.ufes.inf.lprm.situation.model.Situation; import org.drools.core.base.ValueType; import org.drools.core.base.evaluators.AfterEvaluatorDefinition; import org.drools.core.common.EventFactHandle; import org.drools.core.common.InternalFactHandle; package br.ufes.inf.lprm.scene.base.evaluators.implementation; public class AfterEvaluator extends AfterEvaluatorDefinition.AfterEvaluator { public AfterEvaluator( final ValueType type, final boolean isNegated, final long[] parameters, final String paramText, final boolean unwrapLeft, final boolean unwrapRight ) { super( type, isNegated, parameters, paramText, unwrapLeft, unwrapRight ); } @Override protected long getLeftTimestamp( InternalFactHandle handle ) { Object obj = handle.getObject();
if (obj instanceof Situation) {
pextralabs/scene-platform
scene-core/src/main/java/br/ufes/inf/lprm/scene/model/events/SituationEvent.java
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // }
import br.ufes.inf.lprm.situation.model.Situation; import java.io.Serializable;
package br.ufes.inf.lprm.scene.model.events; public class SituationEvent implements Serializable, br.ufes.inf.lprm.situation.model.events.SituationEvent { private static final long serialVersionUID = -6112684277674462302L; private long timestamp;
// Path: situation-model/src/main/java/br/ufes/inf/lprm/situation/model/Situation.java // public interface Situation { // // public long getUID(); // public SituationEvent getActivation(); // public SituationEvent getDeactivation(); // public void setDeactivation(SituationEvent deactivation); // public boolean isActive(); // public List<? extends Participation> getParticipations(); // public SituationType getType(); // } // Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/model/events/SituationEvent.java import br.ufes.inf.lprm.situation.model.Situation; import java.io.Serializable; package br.ufes.inf.lprm.scene.model.events; public class SituationEvent implements Serializable, br.ufes.inf.lprm.situation.model.events.SituationEvent { private static final long serialVersionUID = -6112684277674462302L; private long timestamp;
private Situation situation;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/PaletteValidator.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // }
import warehouse.BoxLabel; import java.util.HashSet; import java.util.Set;
package warehouse.products; /** * Created by michal on 23.10.2017. */ public class PaletteValidator implements StorageUnitValidator { @Override public ValidationResult validate(RegisterNew registerNew) { Set<String> violations = new HashSet<>();
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // Path: warehouse-model/src/main/java/warehouse/products/PaletteValidator.java import warehouse.BoxLabel; import java.util.HashSet; import java.util.Set; package warehouse.products; /** * Created by michal on 23.10.2017. */ public class PaletteValidator implements StorageUnitValidator { @Override public ValidationResult validate(RegisterNew registerNew) { Set<String> violations = new HashSet<>();
BoxLabel first = registerNew.getScannedBoxes().get(0);
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/quality/Locked.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // }
import lombok.Value; import warehouse.PaletteLabel;
package warehouse.quality; /** * Created by michal on 10.08.2016. */ @Value public class Locked {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java import lombok.Value; import warehouse.PaletteLabel; package warehouse.quality; /** * Created by michal on 10.08.2016. */ @Value public class Locked {
private final PaletteLabel paletteLabel;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/Picked.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location;
package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Picked {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/main/java/warehouse/products/Picked.java import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location; package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Picked {
private final PaletteLabel paletteLabel;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/Picked.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location;
package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Picked { private final PaletteLabel paletteLabel; private final String user;
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/main/java/warehouse/products/Picked.java import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location; package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Picked { private final PaletteLabel paletteLabel; private final String user;
private final Location previousLocation;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/Pick.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // }
import lombok.Value; import warehouse.PaletteLabel;
package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Pick {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // Path: warehouse-model/src/main/java/warehouse/products/Pick.java import lombok.Value; import warehouse.PaletteLabel; package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Pick {
private final PaletteLabel paletteLabel;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/CartValidator.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // }
import lombok.Value; import warehouse.BoxLabel; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; import static java.util.stream.Collectors.toMap;
package warehouse.products; /** * Created by michal on 23.10.2017. */ public class CartValidator implements StorageUnitValidator { private final String refNo; private final Map<String, Integer> requiredPositions; public CartValidator(String refNo, List<String> requiredProducts) { this.refNo = refNo; this.requiredPositions = Collections.unmodifiableMap( IntStream.range(0, requiredProducts.size()).boxed() .collect(toMap(requiredProducts::get, Function.identity())) ); } @Override public ValidationResult validate(RegisterNew registerNew) { Stream<String> notExpected = scanned(registerNew) .filter(Scanned::isViolated) .map(Scanned::violation); Stream<String> notFound = notFound(registerNew) .map(this::notFoundMessage); return new ValidationResult( Stream.concat(notFound, notExpected) .collect(Collectors.toSet()) ); } private Stream<String> notFound(RegisterNew registerNew) { Set<String> actual = scannedRefNos(registerNew).collect(Collectors.toSet()); return expected().filter(expected -> !actual.contains(expected)); } private Stream<String> scannedRefNos(RegisterNew registerNew) { return registerNew.getScannedBoxes().stream()
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // Path: warehouse-model/src/main/java/warehouse/products/CartValidator.java import lombok.Value; import warehouse.BoxLabel; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; import static java.util.stream.Collectors.toMap; package warehouse.products; /** * Created by michal on 23.10.2017. */ public class CartValidator implements StorageUnitValidator { private final String refNo; private final Map<String, Integer> requiredPositions; public CartValidator(String refNo, List<String> requiredProducts) { this.refNo = refNo; this.requiredPositions = Collections.unmodifiableMap( IntStream.range(0, requiredProducts.size()).boxed() .collect(toMap(requiredProducts::get, Function.identity())) ); } @Override public ValidationResult validate(RegisterNew registerNew) { Stream<String> notExpected = scanned(registerNew) .filter(Scanned::isViolated) .map(Scanned::violation); Stream<String> notFound = notFound(registerNew) .map(this::notFoundMessage); return new ValidationResult( Stream.concat(notFound, notExpected) .collect(Collectors.toSet()) ); } private Stream<String> notFound(RegisterNew registerNew) { Set<String> actual = scannedRefNos(registerNew).collect(Collectors.toSet()); return expected().filter(expected -> !actual.contains(expected)); } private Stream<String> scannedRefNos(RegisterNew registerNew) { return registerNew.getScannedBoxes().stream()
.map(BoxLabel::getRefNo);
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/products/RegistrationAndStoringSteps.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java // public static RefNoLocation l(String refNo, Location location) { // return new RefNoLocation(refNo, location); // }
import cucumber.api.PendingException; import cucumber.api.java.Before; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import org.assertj.core.api.Assertions; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static warehouse.products.ProductStockBuilder.l;
package warehouse.products; /** * Created by michal on 08.06.2016. */ public class RegistrationAndStoringSteps { private PaletteLabel paletteLabel;
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java // public static RefNoLocation l(String refNo, Location location) { // return new RefNoLocation(refNo, location); // } // Path: warehouse-model/src/test/java/warehouse/products/RegistrationAndStoringSteps.java import cucumber.api.PendingException; import cucumber.api.java.Before; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import org.assertj.core.api.Assertions; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static warehouse.products.ProductStockBuilder.l; package warehouse.products; /** * Created by michal on 08.06.2016. */ public class RegistrationAndStoringSteps { private PaletteLabel paletteLabel;
private List<BoxLabel> scannedBoxes = new ArrayList<>();
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/products/RegistrationAndStoringSteps.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java // public static RefNoLocation l(String refNo, Location location) { // return new RefNoLocation(refNo, location); // }
import cucumber.api.PendingException; import cucumber.api.java.Before; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import org.assertj.core.api.Assertions; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static warehouse.products.ProductStockBuilder.l;
package warehouse.products; /** * Created by michal on 08.06.2016. */ public class RegistrationAndStoringSteps { private PaletteLabel paletteLabel; private List<BoxLabel> scannedBoxes = new ArrayList<>(); private ProductStock object; private EventsAssert events = new EventsAssert();
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java // public static RefNoLocation l(String refNo, Location location) { // return new RefNoLocation(refNo, location); // } // Path: warehouse-model/src/test/java/warehouse/products/RegistrationAndStoringSteps.java import cucumber.api.PendingException; import cucumber.api.java.Before; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import org.assertj.core.api.Assertions; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static warehouse.products.ProductStockBuilder.l; package warehouse.products; /** * Created by michal on 08.06.2016. */ public class RegistrationAndStoringSteps { private PaletteLabel paletteLabel; private List<BoxLabel> scannedBoxes = new ArrayList<>(); private ProductStock object; private EventsAssert events = new EventsAssert();
private TLabelsFormats generator = new TLabelsFormats(0);
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/products/RegistrationAndStoringSteps.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java // public static RefNoLocation l(String refNo, Location location) { // return new RefNoLocation(refNo, location); // }
import cucumber.api.PendingException; import cucumber.api.java.Before; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import org.assertj.core.api.Assertions; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static warehouse.products.ProductStockBuilder.l;
package warehouse.products; /** * Created by michal on 08.06.2016. */ public class RegistrationAndStoringSteps { private PaletteLabel paletteLabel; private List<BoxLabel> scannedBoxes = new ArrayList<>(); private ProductStock object; private EventsAssert events = new EventsAssert(); private TLabelsFormats generator = new TLabelsFormats(0); @Before public void setUp() throws Exception { object = ProductStockBuilder.forRefNo("900300")
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java // public static RefNoLocation l(String refNo, Location location) { // return new RefNoLocation(refNo, location); // } // Path: warehouse-model/src/test/java/warehouse/products/RegistrationAndStoringSteps.java import cucumber.api.PendingException; import cucumber.api.java.Before; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import org.assertj.core.api.Assertions; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static warehouse.products.ProductStockBuilder.l; package warehouse.products; /** * Created by michal on 08.06.2016. */ public class RegistrationAndStoringSteps { private PaletteLabel paletteLabel; private List<BoxLabel> scannedBoxes = new ArrayList<>(); private ProductStock object; private EventsAssert events = new EventsAssert(); private TLabelsFormats generator = new TLabelsFormats(0); @Before public void setUp() throws Exception { object = ProductStockBuilder.forRefNo("900300")
.locationsPicker(l("900300", new Location("A-32-3")))
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/products/RegistrationAndStoringSteps.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java // public static RefNoLocation l(String refNo, Location location) { // return new RefNoLocation(refNo, location); // }
import cucumber.api.PendingException; import cucumber.api.java.Before; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import org.assertj.core.api.Assertions; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static warehouse.products.ProductStockBuilder.l;
package warehouse.products; /** * Created by michal on 08.06.2016. */ public class RegistrationAndStoringSteps { private PaletteLabel paletteLabel; private List<BoxLabel> scannedBoxes = new ArrayList<>(); private ProductStock object; private EventsAssert events = new EventsAssert(); private TLabelsFormats generator = new TLabelsFormats(0); @Before public void setUp() throws Exception { object = ProductStockBuilder.forRefNo("900300")
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java // public static RefNoLocation l(String refNo, Location location) { // return new RefNoLocation(refNo, location); // } // Path: warehouse-model/src/test/java/warehouse/products/RegistrationAndStoringSteps.java import cucumber.api.PendingException; import cucumber.api.java.Before; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import org.assertj.core.api.Assertions; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static warehouse.products.ProductStockBuilder.l; package warehouse.products; /** * Created by michal on 08.06.2016. */ public class RegistrationAndStoringSteps { private PaletteLabel paletteLabel; private List<BoxLabel> scannedBoxes = new ArrayList<>(); private ProductStock object; private EventsAssert events = new EventsAssert(); private TLabelsFormats generator = new TLabelsFormats(0); @Before public void setUp() throws Exception { object = ProductStockBuilder.forRefNo("900300")
.locationsPicker(l("900300", new Location("A-32-3")))
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map;
package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @Setter @Accessors(fluent = true) public class FifoBuilder {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map; package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @Setter @Accessors(fluent = true) public class FifoBuilder {
private final Map<PaletteLabel, Location> locations = new HashMap<>();
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map;
package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @Setter @Accessors(fluent = true) public class FifoBuilder {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map; package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @Setter @Accessors(fluent = true) public class FifoBuilder {
private final Map<PaletteLabel, Location> locations = new HashMap<>();
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map;
package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @Setter @Accessors(fluent = true) public class FifoBuilder { private final Map<PaletteLabel, Location> locations = new HashMap<>(); private final Map<String, Fifo.PerProduct> products = new HashMap<>(); private Location unknown = Location.unknown(); public static FifoBuilder builder() { return new FifoBuilder(); } public Fifo build() { return new Fifo(p -> locations.getOrDefault(p, unknown), this::product); } private Fifo.PerProduct product(String refNo) { return products.computeIfAbsent(refNo, ref -> new Fifo.PerProduct()); } public History history() { return new History(build()); } public class History { private final Fifo object; private History(Fifo object) { this.object = object; } public Fifo get() { return object; } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt, Location storedAt) { Fifo.PerProduct product = product(paletteLabel.getRefNo());
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map; package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @Setter @Accessors(fluent = true) public class FifoBuilder { private final Map<PaletteLabel, Location> locations = new HashMap<>(); private final Map<String, Fifo.PerProduct> products = new HashMap<>(); private Location unknown = Location.unknown(); public static FifoBuilder builder() { return new FifoBuilder(); } public Fifo build() { return new Fifo(p -> locations.getOrDefault(p, unknown), this::product); } private Fifo.PerProduct product(String refNo) { return products.computeIfAbsent(refNo, ref -> new Fifo.PerProduct()); } public History history() { return new History(build()); } public class History { private final Fifo object; private History(Fifo object) { this.object = object; } public Fifo get() { return object; } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt, Location storedAt) { Fifo.PerProduct product = product(paletteLabel.getRefNo());
product.apply(new Registered(paletteLabel, Collections.emptyList(), producedAt, storedAt));
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map;
private Fifo.PerProduct product(String refNo) { return products.computeIfAbsent(refNo, ref -> new Fifo.PerProduct()); } public History history() { return new History(build()); } public class History { private final Fifo object; private History(Fifo object) { this.object = object; } public Fifo get() { return object; } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt, Location storedAt) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Registered(paletteLabel, Collections.emptyList(), producedAt, storedAt)); locations.put(paletteLabel, storedAt); return this; } public History delivered(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo());
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map; private Fifo.PerProduct product(String refNo) { return products.computeIfAbsent(refNo, ref -> new Fifo.PerProduct()); } public History history() { return new History(build()); } public class History { private final Fifo object; private History(Fifo object) { this.object = object; } public Fifo get() { return object; } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt, Location storedAt) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Registered(paletteLabel, Collections.emptyList(), producedAt, storedAt)); locations.put(paletteLabel, storedAt); return this; } public History delivered(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo());
product.apply(new Delivered(paletteLabel));
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map;
return new History(build()); } public class History { private final Fifo object; private History(Fifo object) { this.object = object; } public Fifo get() { return object; } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt, Location storedAt) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Registered(paletteLabel, Collections.emptyList(), producedAt, storedAt)); locations.put(paletteLabel, storedAt); return this; } public History delivered(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Delivered(paletteLabel)); return this; } public History locked(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo());
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map; return new History(build()); } public class History { private final Fifo object; private History(Fifo object) { this.object = object; } public Fifo get() { return object; } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt, Location storedAt) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Registered(paletteLabel, Collections.emptyList(), producedAt, storedAt)); locations.put(paletteLabel, storedAt); return this; } public History delivered(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Delivered(paletteLabel)); return this; } public History locked(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo());
product.apply(new Locked(paletteLabel));
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map;
private History(Fifo object) { this.object = object; } public Fifo get() { return object; } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt, Location storedAt) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Registered(paletteLabel, Collections.emptyList(), producedAt, storedAt)); locations.put(paletteLabel, storedAt); return this; } public History delivered(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Delivered(paletteLabel)); return this; } public History locked(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Locked(paletteLabel)); return this; } public History unlocked(PaletteLabel paletteLabel, int recovered, int scraped) { Fifo.PerProduct product = product(paletteLabel.getRefNo());
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map; private History(Fifo object) { this.object = object; } public Fifo get() { return object; } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt, Location storedAt) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Registered(paletteLabel, Collections.emptyList(), producedAt, storedAt)); locations.put(paletteLabel, storedAt); return this; } public History delivered(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Delivered(paletteLabel)); return this; } public History locked(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Locked(paletteLabel)); return this; } public History unlocked(PaletteLabel paletteLabel, int recovered, int scraped) { Fifo.PerProduct product = product(paletteLabel.getRefNo());
product.apply(new Unlocked(paletteLabel, recovered, scraped));
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map;
return object; } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt, Location storedAt) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Registered(paletteLabel, Collections.emptyList(), producedAt, storedAt)); locations.put(paletteLabel, storedAt); return this; } public History delivered(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Delivered(paletteLabel)); return this; } public History locked(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Locked(paletteLabel)); return this; } public History unlocked(PaletteLabel paletteLabel, int recovered, int scraped) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Unlocked(paletteLabel, recovered, scraped)); return this; } public History destroyed(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo());
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/test/java/warehouse/picklist/FifoBuilder.java import lombok.Setter; import lombok.experimental.Accessors; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashMap; import java.util.Map; return object; } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt, Location storedAt) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Registered(paletteLabel, Collections.emptyList(), producedAt, storedAt)); locations.put(paletteLabel, storedAt); return this; } public History delivered(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Delivered(paletteLabel)); return this; } public History locked(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Locked(paletteLabel)); return this; } public History unlocked(PaletteLabel paletteLabel, int recovered, int scraped) { Fifo.PerProduct product = product(paletteLabel.getRefNo()); product.apply(new Unlocked(paletteLabel, recovered, scraped)); return this; } public History destroyed(PaletteLabel paletteLabel) { Fifo.PerProduct product = product(paletteLabel.getRefNo());
product.apply(new Destroyed(paletteLabel));
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/BasicLocationPicker.java // @AllArgsConstructor // public class BasicLocationPicker implements PreferredLocationPicker { // private final Map<String, Location> perRefNo; // private final Location def = Location.unknown(); // // @Override // public Location suggestFor(String refNo) { // return perRefNo.getOrDefault(refNo, def); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // }
import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.BasicLocationPicker; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import java.time.Clock; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream;
package warehouse.products; /** * Created by michal on 15.07.2016. */ @Setter @Accessors(fluent = true) public class ProductStockBuilder { private final String refNo;
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/BasicLocationPicker.java // @AllArgsConstructor // public class BasicLocationPicker implements PreferredLocationPicker { // private final Map<String, Location> perRefNo; // private final Location def = Location.unknown(); // // @Override // public Location suggestFor(String refNo) { // return perRefNo.getOrDefault(refNo, def); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.BasicLocationPicker; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import java.time.Clock; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; package warehouse.products; /** * Created by michal on 15.07.2016. */ @Setter @Accessors(fluent = true) public class ProductStockBuilder { private final String refNo;
private PreferredLocationPicker locationsPicker = new BasicLocationPicker(Collections.emptyMap());
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/BasicLocationPicker.java // @AllArgsConstructor // public class BasicLocationPicker implements PreferredLocationPicker { // private final Map<String, Location> perRefNo; // private final Location def = Location.unknown(); // // @Override // public Location suggestFor(String refNo) { // return perRefNo.getOrDefault(refNo, def); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // }
import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.BasicLocationPicker; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import java.time.Clock; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream;
package warehouse.products; /** * Created by michal on 15.07.2016. */ @Setter @Accessors(fluent = true) public class ProductStockBuilder { private final String refNo;
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/BasicLocationPicker.java // @AllArgsConstructor // public class BasicLocationPicker implements PreferredLocationPicker { // private final Map<String, Location> perRefNo; // private final Location def = Location.unknown(); // // @Override // public Location suggestFor(String refNo) { // return perRefNo.getOrDefault(refNo, def); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.BasicLocationPicker; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import java.time.Clock; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; package warehouse.products; /** * Created by michal on 15.07.2016. */ @Setter @Accessors(fluent = true) public class ProductStockBuilder { private final String refNo;
private PreferredLocationPicker locationsPicker = new BasicLocationPicker(Collections.emptyMap());
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/BasicLocationPicker.java // @AllArgsConstructor // public class BasicLocationPicker implements PreferredLocationPicker { // private final Map<String, Location> perRefNo; // private final Location def = Location.unknown(); // // @Override // public Location suggestFor(String refNo) { // return perRefNo.getOrDefault(refNo, def); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // }
import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.BasicLocationPicker; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import java.time.Clock; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream;
package warehouse.products; /** * Created by michal on 15.07.2016. */ @Setter @Accessors(fluent = true) public class ProductStockBuilder { private final String refNo; private PreferredLocationPicker locationsPicker = new BasicLocationPicker(Collections.emptyMap()); private EventsAssert events = new EventsAssert(); private Clock clock = Clock.systemDefaultZone(); private PaletteValidator validator = new PaletteValidator(); public static ProductStockBuilder forRefNo(String refNo) { return new ProductStockBuilder(refNo); }
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/BasicLocationPicker.java // @AllArgsConstructor // public class BasicLocationPicker implements PreferredLocationPicker { // private final Map<String, Location> perRefNo; // private final Location def = Location.unknown(); // // @Override // public Location suggestFor(String refNo) { // return perRefNo.getOrDefault(refNo, def); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.BasicLocationPicker; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import java.time.Clock; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; package warehouse.products; /** * Created by michal on 15.07.2016. */ @Setter @Accessors(fluent = true) public class ProductStockBuilder { private final String refNo; private PreferredLocationPicker locationsPicker = new BasicLocationPicker(Collections.emptyMap()); private EventsAssert events = new EventsAssert(); private Clock clock = Clock.systemDefaultZone(); private PaletteValidator validator = new PaletteValidator(); public static ProductStockBuilder forRefNo(String refNo) { return new ProductStockBuilder(refNo); }
public static RefNoLocation l(String refNo, Location location) {
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/BasicLocationPicker.java // @AllArgsConstructor // public class BasicLocationPicker implements PreferredLocationPicker { // private final Map<String, Location> perRefNo; // private final Location def = Location.unknown(); // // @Override // public Location suggestFor(String refNo) { // return perRefNo.getOrDefault(refNo, def); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // }
import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.BasicLocationPicker; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import java.time.Clock; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream;
public ProductStock build() { return new ProductStock(refNo, locationsPicker, validator, events, clock); } public ProductStockBuilder locationsPicker(RefNoLocation... locations) { locationsPicker = new BasicLocationPicker(Stream.of(locations) .collect(Collectors.toMap(RefNoLocation::refNo, RefNoLocation::location))); return this; } public History history() { return new History(build()); } private ProductStockBuilder(String refNo) { this.refNo = refNo; } public class History { private final ProductStock object; private History(ProductStock object) { this.object = object; } public ProductStock get() { return object; }
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/BasicLocationPicker.java // @AllArgsConstructor // public class BasicLocationPicker implements PreferredLocationPicker { // private final Map<String, Location> perRefNo; // private final Location def = Location.unknown(); // // @Override // public Location suggestFor(String refNo) { // return perRefNo.getOrDefault(refNo, def); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.BasicLocationPicker; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import java.time.Clock; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; public ProductStock build() { return new ProductStock(refNo, locationsPicker, validator, events, clock); } public ProductStockBuilder locationsPicker(RefNoLocation... locations) { locationsPicker = new BasicLocationPicker(Stream.of(locations) .collect(Collectors.toMap(RefNoLocation::refNo, RefNoLocation::location))); return this; } public History history() { return new History(build()); } private ProductStockBuilder(String refNo) { this.refNo = refNo; } public class History { private final ProductStock object; private History(ProductStock object) { this.object = object; } public ProductStock get() { return object; }
public History newPalette(PaletteLabel paletteLabel) {
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/BasicLocationPicker.java // @AllArgsConstructor // public class BasicLocationPicker implements PreferredLocationPicker { // private final Map<String, Location> perRefNo; // private final Location def = Location.unknown(); // // @Override // public Location suggestFor(String refNo) { // return perRefNo.getOrDefault(refNo, def); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // }
import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.BasicLocationPicker; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import java.time.Clock; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream;
return object; } public History newPalette(PaletteLabel paletteLabel) { return newPalette(paletteLabel, LocalDateTime.now(clock), locationsPicker.suggestFor(paletteLabel.getRefNo())); } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt) { return newPalette(paletteLabel, producedAt, locationsPicker.suggestFor(paletteLabel.getRefNo())); } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt, Location preferredLocation) { Registered event = new Registered( paletteLabel, someBoxesFor(paletteLabel.getRefNo()), producedAt, preferredLocation ); object.apply(event); return this; } public History stored(PaletteLabel paletteLabel, Location location) { object.apply(new Stored(paletteLabel, location)); return this; } public History picked(PaletteLabel paletteLabel, Location location, String user) { object.apply(new Picked(paletteLabel, user, location, Location.onTheMove(user))); return this; }
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/BasicLocationPicker.java // @AllArgsConstructor // public class BasicLocationPicker implements PreferredLocationPicker { // private final Map<String, Location> perRefNo; // private final Location def = Location.unknown(); // // @Override // public Location suggestFor(String refNo) { // return perRefNo.getOrDefault(refNo, def); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // Path: warehouse-model/src/test/java/warehouse/products/ProductStockBuilder.java import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.BasicLocationPicker; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import java.time.Clock; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; return object; } public History newPalette(PaletteLabel paletteLabel) { return newPalette(paletteLabel, LocalDateTime.now(clock), locationsPicker.suggestFor(paletteLabel.getRefNo())); } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt) { return newPalette(paletteLabel, producedAt, locationsPicker.suggestFor(paletteLabel.getRefNo())); } public History newPalette(PaletteLabel paletteLabel, LocalDateTime producedAt, Location preferredLocation) { Registered event = new Registered( paletteLabel, someBoxesFor(paletteLabel.getRefNo()), producedAt, preferredLocation ); object.apply(event); return this; } public History stored(PaletteLabel paletteLabel, Location location) { object.apply(new Stored(paletteLabel, location)); return this; } public History picked(PaletteLabel paletteLabel, Location location, String user) { object.apply(new Picked(paletteLabel, user, location, Location.onTheMove(user))); return this; }
private List<BoxLabel> someBoxesFor(String refNo) {
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/picklist/FifoPickingSteps.java
// Path: warehouse-model/src/test/java/tools/FunkyDateHolder.java // public class FunkyDateHolder { // // private LocalDate current = forString("some day"); // private Clock clock; // // public FunkyDateHolder() { // this.clock = Clock.systemDefaultZone(); // } // // public FunkyDateHolder(Clock clock) { // this.clock = clock; // } // // public LocalDateTime get() { // return current.atTime(LocalTime.now(clock)); // } // // public void set(String day) { // current = forString(day); // } // // private LocalDate forString(String day) { // switch (day) { // case "some day": // return LocalDate.of(2016, Month.JANUARY, 8); // case "same day": // return current; // case "next day": // return current.plusDays(1); // default: // return LocalDate.parse(day); // } // } // } // // Path: warehouse-model/src/main/java/warehouse/Labels.java // public interface Labels { // PaletteLabel newPalette(String refNo); // // PaletteLabel scanPalette(String label); // // BoxLabel scanBox(String label); // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import cucumber.api.java.en.And; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import lombok.Data; import org.assertj.core.api.Assertions; import tools.FunkyDateHolder; import warehouse.Labels; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.List;
package warehouse.picklist; /** * Created by michal on 02.07.2016. */ public class FifoPickingSteps { private PickList pickList; @Data public static class StockEntry { private String refNo;
// Path: warehouse-model/src/test/java/tools/FunkyDateHolder.java // public class FunkyDateHolder { // // private LocalDate current = forString("some day"); // private Clock clock; // // public FunkyDateHolder() { // this.clock = Clock.systemDefaultZone(); // } // // public FunkyDateHolder(Clock clock) { // this.clock = clock; // } // // public LocalDateTime get() { // return current.atTime(LocalTime.now(clock)); // } // // public void set(String day) { // current = forString(day); // } // // private LocalDate forString(String day) { // switch (day) { // case "some day": // return LocalDate.of(2016, Month.JANUARY, 8); // case "same day": // return current; // case "next day": // return current.plusDays(1); // default: // return LocalDate.parse(day); // } // } // } // // Path: warehouse-model/src/main/java/warehouse/Labels.java // public interface Labels { // PaletteLabel newPalette(String refNo); // // PaletteLabel scanPalette(String label); // // BoxLabel scanBox(String label); // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/test/java/warehouse/picklist/FifoPickingSteps.java import cucumber.api.java.en.And; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import lombok.Data; import org.assertj.core.api.Assertions; import tools.FunkyDateHolder; import warehouse.Labels; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.List; package warehouse.picklist; /** * Created by michal on 02.07.2016. */ public class FifoPickingSteps { private PickList pickList; @Data public static class StockEntry { private String refNo;
private Location location;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/picklist/FifoPickingSteps.java
// Path: warehouse-model/src/test/java/tools/FunkyDateHolder.java // public class FunkyDateHolder { // // private LocalDate current = forString("some day"); // private Clock clock; // // public FunkyDateHolder() { // this.clock = Clock.systemDefaultZone(); // } // // public FunkyDateHolder(Clock clock) { // this.clock = clock; // } // // public LocalDateTime get() { // return current.atTime(LocalTime.now(clock)); // } // // public void set(String day) { // current = forString(day); // } // // private LocalDate forString(String day) { // switch (day) { // case "some day": // return LocalDate.of(2016, Month.JANUARY, 8); // case "same day": // return current; // case "next day": // return current.plusDays(1); // default: // return LocalDate.parse(day); // } // } // } // // Path: warehouse-model/src/main/java/warehouse/Labels.java // public interface Labels { // PaletteLabel newPalette(String refNo); // // PaletteLabel scanPalette(String label); // // BoxLabel scanBox(String label); // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import cucumber.api.java.en.And; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import lombok.Data; import org.assertj.core.api.Assertions; import tools.FunkyDateHolder; import warehouse.Labels; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.List;
package warehouse.picklist; /** * Created by michal on 02.07.2016. */ public class FifoPickingSteps { private PickList pickList; @Data public static class StockEntry { private String refNo; private Location location; private int amount; private String produced; } @Data public static class Palette { private String label; private Location location; private String produced; }
// Path: warehouse-model/src/test/java/tools/FunkyDateHolder.java // public class FunkyDateHolder { // // private LocalDate current = forString("some day"); // private Clock clock; // // public FunkyDateHolder() { // this.clock = Clock.systemDefaultZone(); // } // // public FunkyDateHolder(Clock clock) { // this.clock = clock; // } // // public LocalDateTime get() { // return current.atTime(LocalTime.now(clock)); // } // // public void set(String day) { // current = forString(day); // } // // private LocalDate forString(String day) { // switch (day) { // case "some day": // return LocalDate.of(2016, Month.JANUARY, 8); // case "same day": // return current; // case "next day": // return current.plusDays(1); // default: // return LocalDate.parse(day); // } // } // } // // Path: warehouse-model/src/main/java/warehouse/Labels.java // public interface Labels { // PaletteLabel newPalette(String refNo); // // PaletteLabel scanPalette(String label); // // BoxLabel scanBox(String label); // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/test/java/warehouse/picklist/FifoPickingSteps.java import cucumber.api.java.en.And; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import lombok.Data; import org.assertj.core.api.Assertions; import tools.FunkyDateHolder; import warehouse.Labels; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.List; package warehouse.picklist; /** * Created by michal on 02.07.2016. */ public class FifoPickingSteps { private PickList pickList; @Data public static class StockEntry { private String refNo; private Location location; private int amount; private String produced; } @Data public static class Palette { private String label; private Location location; private String produced; }
private final Labels generator = new TLabelsFormats(0);
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/picklist/FifoPickingSteps.java
// Path: warehouse-model/src/test/java/tools/FunkyDateHolder.java // public class FunkyDateHolder { // // private LocalDate current = forString("some day"); // private Clock clock; // // public FunkyDateHolder() { // this.clock = Clock.systemDefaultZone(); // } // // public FunkyDateHolder(Clock clock) { // this.clock = clock; // } // // public LocalDateTime get() { // return current.atTime(LocalTime.now(clock)); // } // // public void set(String day) { // current = forString(day); // } // // private LocalDate forString(String day) { // switch (day) { // case "some day": // return LocalDate.of(2016, Month.JANUARY, 8); // case "same day": // return current; // case "next day": // return current.plusDays(1); // default: // return LocalDate.parse(day); // } // } // } // // Path: warehouse-model/src/main/java/warehouse/Labels.java // public interface Labels { // PaletteLabel newPalette(String refNo); // // PaletteLabel scanPalette(String label); // // BoxLabel scanBox(String label); // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import cucumber.api.java.en.And; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import lombok.Data; import org.assertj.core.api.Assertions; import tools.FunkyDateHolder; import warehouse.Labels; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.List;
package warehouse.picklist; /** * Created by michal on 02.07.2016. */ public class FifoPickingSteps { private PickList pickList; @Data public static class StockEntry { private String refNo; private Location location; private int amount; private String produced; } @Data public static class Palette { private String label; private Location location; private String produced; }
// Path: warehouse-model/src/test/java/tools/FunkyDateHolder.java // public class FunkyDateHolder { // // private LocalDate current = forString("some day"); // private Clock clock; // // public FunkyDateHolder() { // this.clock = Clock.systemDefaultZone(); // } // // public FunkyDateHolder(Clock clock) { // this.clock = clock; // } // // public LocalDateTime get() { // return current.atTime(LocalTime.now(clock)); // } // // public void set(String day) { // current = forString(day); // } // // private LocalDate forString(String day) { // switch (day) { // case "some day": // return LocalDate.of(2016, Month.JANUARY, 8); // case "same day": // return current; // case "next day": // return current.plusDays(1); // default: // return LocalDate.parse(day); // } // } // } // // Path: warehouse-model/src/main/java/warehouse/Labels.java // public interface Labels { // PaletteLabel newPalette(String refNo); // // PaletteLabel scanPalette(String label); // // BoxLabel scanBox(String label); // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/test/java/warehouse/picklist/FifoPickingSteps.java import cucumber.api.java.en.And; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import lombok.Data; import org.assertj.core.api.Assertions; import tools.FunkyDateHolder; import warehouse.Labels; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.List; package warehouse.picklist; /** * Created by michal on 02.07.2016. */ public class FifoPickingSteps { private PickList pickList; @Data public static class StockEntry { private String refNo; private Location location; private int amount; private String produced; } @Data public static class Palette { private String label; private Location location; private String produced; }
private final Labels generator = new TLabelsFormats(0);
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/picklist/FifoPickingSteps.java
// Path: warehouse-model/src/test/java/tools/FunkyDateHolder.java // public class FunkyDateHolder { // // private LocalDate current = forString("some day"); // private Clock clock; // // public FunkyDateHolder() { // this.clock = Clock.systemDefaultZone(); // } // // public FunkyDateHolder(Clock clock) { // this.clock = clock; // } // // public LocalDateTime get() { // return current.atTime(LocalTime.now(clock)); // } // // public void set(String day) { // current = forString(day); // } // // private LocalDate forString(String day) { // switch (day) { // case "some day": // return LocalDate.of(2016, Month.JANUARY, 8); // case "same day": // return current; // case "next day": // return current.plusDays(1); // default: // return LocalDate.parse(day); // } // } // } // // Path: warehouse-model/src/main/java/warehouse/Labels.java // public interface Labels { // PaletteLabel newPalette(String refNo); // // PaletteLabel scanPalette(String label); // // BoxLabel scanBox(String label); // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import cucumber.api.java.en.And; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import lombok.Data; import org.assertj.core.api.Assertions; import tools.FunkyDateHolder; import warehouse.Labels; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.List;
package warehouse.picklist; /** * Created by michal on 02.07.2016. */ public class FifoPickingSteps { private PickList pickList; @Data public static class StockEntry { private String refNo; private Location location; private int amount; private String produced; } @Data public static class Palette { private String label; private Location location; private String produced; } private final Labels generator = new TLabelsFormats(0);
// Path: warehouse-model/src/test/java/tools/FunkyDateHolder.java // public class FunkyDateHolder { // // private LocalDate current = forString("some day"); // private Clock clock; // // public FunkyDateHolder() { // this.clock = Clock.systemDefaultZone(); // } // // public FunkyDateHolder(Clock clock) { // this.clock = clock; // } // // public LocalDateTime get() { // return current.atTime(LocalTime.now(clock)); // } // // public void set(String day) { // current = forString(day); // } // // private LocalDate forString(String day) { // switch (day) { // case "some day": // return LocalDate.of(2016, Month.JANUARY, 8); // case "same day": // return current; // case "next day": // return current.plusDays(1); // default: // return LocalDate.parse(day); // } // } // } // // Path: warehouse-model/src/main/java/warehouse/Labels.java // public interface Labels { // PaletteLabel newPalette(String refNo); // // PaletteLabel scanPalette(String label); // // BoxLabel scanBox(String label); // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/test/java/warehouse/picklist/FifoPickingSteps.java import cucumber.api.java.en.And; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import lombok.Data; import org.assertj.core.api.Assertions; import tools.FunkyDateHolder; import warehouse.Labels; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.List; package warehouse.picklist; /** * Created by michal on 02.07.2016. */ public class FifoPickingSteps { private PickList pickList; @Data public static class StockEntry { private String refNo; private Location location; private int amount; private String produced; } @Data public static class Palette { private String label; private Location location; private String produced; } private final Labels generator = new TLabelsFormats(0);
private final FunkyDateHolder prodDate = new FunkyDateHolder();
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/picklist/FifoPickingSteps.java
// Path: warehouse-model/src/test/java/tools/FunkyDateHolder.java // public class FunkyDateHolder { // // private LocalDate current = forString("some day"); // private Clock clock; // // public FunkyDateHolder() { // this.clock = Clock.systemDefaultZone(); // } // // public FunkyDateHolder(Clock clock) { // this.clock = clock; // } // // public LocalDateTime get() { // return current.atTime(LocalTime.now(clock)); // } // // public void set(String day) { // current = forString(day); // } // // private LocalDate forString(String day) { // switch (day) { // case "some day": // return LocalDate.of(2016, Month.JANUARY, 8); // case "same day": // return current; // case "next day": // return current.plusDays(1); // default: // return LocalDate.parse(day); // } // } // } // // Path: warehouse-model/src/main/java/warehouse/Labels.java // public interface Labels { // PaletteLabel newPalette(String refNo); // // PaletteLabel scanPalette(String label); // // BoxLabel scanBox(String label); // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import cucumber.api.java.en.And; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import lombok.Data; import org.assertj.core.api.Assertions; import tools.FunkyDateHolder; import warehouse.Labels; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.List;
private final Labels generator = new TLabelsFormats(0); private final FunkyDateHolder prodDate = new FunkyDateHolder(); private final FifoBuilder.History builder = FifoBuilder.builder().history(); private final Order.OrderBuilder order = Order.builder(); @Given("^stock of:$") public void stockOf(List<StockEntry> stock) throws Throwable { for (StockEntry entry : stock) { palettesOfStoredAtLocation(entry.amount, entry.refNo, entry.produced, entry.location); } } @Given("^(\\d+) palettes of (\\d+) produced (.+) stored at (.+) location$") public void palettesOfStoredAtLocation(int count, String refNo, String day, Location location) throws Throwable { prodDate.set(day); for (int i = 0; i < count; i++) { builder.newPalette(generator.newPalette(refNo), prodDate.get(), location); } } @Given("^palettes:$") public void palettes(List<Palette> palettes) throws Throwable { for (Palette entry : palettes) { paletteStoredAtLocation(generator.scanPalette(entry.label), entry.produced, entry.location); } } @Given("^palette (\\d+) produced (.+) stored at (.+) location$")
// Path: warehouse-model/src/test/java/tools/FunkyDateHolder.java // public class FunkyDateHolder { // // private LocalDate current = forString("some day"); // private Clock clock; // // public FunkyDateHolder() { // this.clock = Clock.systemDefaultZone(); // } // // public FunkyDateHolder(Clock clock) { // this.clock = clock; // } // // public LocalDateTime get() { // return current.atTime(LocalTime.now(clock)); // } // // public void set(String day) { // current = forString(day); // } // // private LocalDate forString(String day) { // switch (day) { // case "some day": // return LocalDate.of(2016, Month.JANUARY, 8); // case "same day": // return current; // case "next day": // return current.plusDays(1); // default: // return LocalDate.parse(day); // } // } // } // // Path: warehouse-model/src/main/java/warehouse/Labels.java // public interface Labels { // PaletteLabel newPalette(String refNo); // // PaletteLabel scanPalette(String label); // // BoxLabel scanBox(String label); // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/TLabelsFormats.java // public class TLabelsFormats implements Labels { // // private final AtomicInteger index; // // public TLabelsFormats(int lastIndex) { // this.index = new AtomicInteger(lastIndex); // } // // @Override // public PaletteLabel newPalette(String refNo) { // String suffix = String.format("%04X", index.getAndIncrement()); // return new PaletteLabel("P-" + refNo + "-" + suffix, refNo); // } // // @Override // public PaletteLabel scanPalette(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("P-")) { // throw new IllegalArgumentException("Label need to start with 'P-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces.length != 3) { // throw new IllegalArgumentException("Label need to have two '-' characters, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[1].isEmpty()) { // throw new IllegalArgumentException("Label has empty refNo, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // if (pieces[2].isEmpty()) { // throw new IllegalArgumentException("Label has empty index, format: P-<refNo>-<index>, ex: P-900300-8A3"); // } // return new PaletteLabel(label, pieces[1]); // } // // @Override // public BoxLabel scanBox(String label) { // String[] pieces = label.split("-"); // if (!label.startsWith("B-")) { // throw new IllegalArgumentException("Label need to start with 'B-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // if (pieces.length != 4) { // throw new IllegalArgumentException("Label need to have three '-' characters, format: B-<refNo>-<quantity>-<boxType>, ex: B-900300-24-B"); // } // return new BoxLabel(pieces[1], Integer.valueOf(pieces[2]), pieces[3]); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/test/java/warehouse/picklist/FifoPickingSteps.java import cucumber.api.java.en.And; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import lombok.Data; import org.assertj.core.api.Assertions; import tools.FunkyDateHolder; import warehouse.Labels; import warehouse.PaletteLabel; import warehouse.TLabelsFormats; import warehouse.locations.Location; import java.util.List; private final Labels generator = new TLabelsFormats(0); private final FunkyDateHolder prodDate = new FunkyDateHolder(); private final FifoBuilder.History builder = FifoBuilder.builder().history(); private final Order.OrderBuilder order = Order.builder(); @Given("^stock of:$") public void stockOf(List<StockEntry> stock) throws Throwable { for (StockEntry entry : stock) { palettesOfStoredAtLocation(entry.amount, entry.refNo, entry.produced, entry.location); } } @Given("^(\\d+) palettes of (\\d+) produced (.+) stored at (.+) location$") public void palettesOfStoredAtLocation(int count, String refNo, String day, Location location) throws Throwable { prodDate.set(day); for (int i = 0; i < count; i++) { builder.newPalette(generator.newPalette(refNo), prodDate.get(), location); } } @Given("^palettes:$") public void palettes(List<Palette> palettes) throws Throwable { for (Palette entry : palettes) { paletteStoredAtLocation(generator.scanPalette(entry.label), entry.produced, entry.location); } } @Given("^palette (\\d+) produced (.+) stored at (.+) location$")
public void paletteStoredAtLocation(PaletteLabel label, String day, Location location) {
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/picklist/PickList.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import lombok.Builder; import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.util.Collections; import java.util.LinkedList; import java.util.List;
package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @Value @Builder public class PickList { private final List<Pick> picks; private PickList(List<Pick> picks) { this.picks = Collections.unmodifiableList(picks); } @Value public static class Pick {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/main/java/warehouse/picklist/PickList.java import lombok.Builder; import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.util.Collections; import java.util.LinkedList; import java.util.List; package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @Value @Builder public class PickList { private final List<Pick> picks; private PickList(List<Pick> picks) { this.picks = Collections.unmodifiableList(picks); } @Value public static class Pick {
private final PaletteLabel paletteLabel;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/picklist/PickList.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import lombok.Builder; import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.util.Collections; import java.util.LinkedList; import java.util.List;
package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @Value @Builder public class PickList { private final List<Pick> picks; private PickList(List<Pick> picks) { this.picks = Collections.unmodifiableList(picks); } @Value public static class Pick { private final PaletteLabel paletteLabel;
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/main/java/warehouse/picklist/PickList.java import lombok.Builder; import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.util.Collections; import java.util.LinkedList; import java.util.List; package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @Value @Builder public class PickList { private final List<Pick> picks; private PickList(List<Pick> picks) { this.picks = Collections.unmodifiableList(picks); } @Value public static class Pick { private final PaletteLabel paletteLabel;
private final Location location;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/Registered.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/ValidationResult.java // public static ValidationResult valid() { // return new ValidationResult(Collections.emptySet()); // }
import lombok.AllArgsConstructor; import lombok.Value; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import static warehouse.products.ValidationResult.valid;
package warehouse.products; /** * Created by michal on 08.06.2016. */ @Value @AllArgsConstructor public class Registered {
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/ValidationResult.java // public static ValidationResult valid() { // return new ValidationResult(Collections.emptySet()); // } // Path: warehouse-model/src/main/java/warehouse/products/Registered.java import lombok.AllArgsConstructor; import lombok.Value; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import static warehouse.products.ValidationResult.valid; package warehouse.products; /** * Created by michal on 08.06.2016. */ @Value @AllArgsConstructor public class Registered {
private final PaletteLabel paletteLabel;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/Registered.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/ValidationResult.java // public static ValidationResult valid() { // return new ValidationResult(Collections.emptySet()); // }
import lombok.AllArgsConstructor; import lombok.Value; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import static warehouse.products.ValidationResult.valid;
package warehouse.products; /** * Created by michal on 08.06.2016. */ @Value @AllArgsConstructor public class Registered { private final PaletteLabel paletteLabel;
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/ValidationResult.java // public static ValidationResult valid() { // return new ValidationResult(Collections.emptySet()); // } // Path: warehouse-model/src/main/java/warehouse/products/Registered.java import lombok.AllArgsConstructor; import lombok.Value; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import static warehouse.products.ValidationResult.valid; package warehouse.products; /** * Created by michal on 08.06.2016. */ @Value @AllArgsConstructor public class Registered { private final PaletteLabel paletteLabel;
private final List<BoxLabel> scannedBoxes;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/Registered.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/ValidationResult.java // public static ValidationResult valid() { // return new ValidationResult(Collections.emptySet()); // }
import lombok.AllArgsConstructor; import lombok.Value; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import static warehouse.products.ValidationResult.valid;
package warehouse.products; /** * Created by michal on 08.06.2016. */ @Value @AllArgsConstructor public class Registered { private final PaletteLabel paletteLabel; private final List<BoxLabel> scannedBoxes; private final LocalDateTime readyAt;
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/ValidationResult.java // public static ValidationResult valid() { // return new ValidationResult(Collections.emptySet()); // } // Path: warehouse-model/src/main/java/warehouse/products/Registered.java import lombok.AllArgsConstructor; import lombok.Value; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import static warehouse.products.ValidationResult.valid; package warehouse.products; /** * Created by michal on 08.06.2016. */ @Value @AllArgsConstructor public class Registered { private final PaletteLabel paletteLabel; private final List<BoxLabel> scannedBoxes; private final LocalDateTime readyAt;
private final Location preferredLocation;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/Registered.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/ValidationResult.java // public static ValidationResult valid() { // return new ValidationResult(Collections.emptySet()); // }
import lombok.AllArgsConstructor; import lombok.Value; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import static warehouse.products.ValidationResult.valid;
package warehouse.products; /** * Created by michal on 08.06.2016. */ @Value @AllArgsConstructor public class Registered { private final PaletteLabel paletteLabel; private final List<BoxLabel> scannedBoxes; private final LocalDateTime readyAt; private final Location preferredLocation; private final ValidationResult validationResult; public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, LocalDateTime readyAt, Location preferredLocation) { this.paletteLabel = paletteLabel; this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); this.readyAt = readyAt; this.preferredLocation = preferredLocation;
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/ValidationResult.java // public static ValidationResult valid() { // return new ValidationResult(Collections.emptySet()); // } // Path: warehouse-model/src/main/java/warehouse/products/Registered.java import lombok.AllArgsConstructor; import lombok.Value; import warehouse.BoxLabel; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import static warehouse.products.ValidationResult.valid; package warehouse.products; /** * Created by michal on 08.06.2016. */ @Value @AllArgsConstructor public class Registered { private final PaletteLabel paletteLabel; private final List<BoxLabel> scannedBoxes; private final LocalDateTime readyAt; private final Location preferredLocation; private final ValidationResult validationResult; public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, LocalDateTime readyAt, Location preferredLocation) { this.paletteLabel = paletteLabel; this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); this.readyAt = readyAt; this.preferredLocation = preferredLocation;
validationResult = valid();
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/RegisterNew.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // }
import lombok.Value; import warehouse.BoxLabel; import warehouse.PaletteLabel; import java.util.Collections; import java.util.List;
package warehouse.products; /** * Created by michal on 08.06.2016. */ @Value public class RegisterNew {
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // Path: warehouse-model/src/main/java/warehouse/products/RegisterNew.java import lombok.Value; import warehouse.BoxLabel; import warehouse.PaletteLabel; import java.util.Collections; import java.util.List; package warehouse.products; /** * Created by michal on 08.06.2016. */ @Value public class RegisterNew {
private final PaletteLabel paletteLabel;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/RegisterNew.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // }
import lombok.Value; import warehouse.BoxLabel; import warehouse.PaletteLabel; import java.util.Collections; import java.util.List;
package warehouse.products; /** * Created by michal on 08.06.2016. */ @Value public class RegisterNew { private final PaletteLabel paletteLabel;
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // Path: warehouse-model/src/main/java/warehouse/products/RegisterNew.java import lombok.Value; import warehouse.BoxLabel; import warehouse.PaletteLabel; import java.util.Collections; import java.util.List; package warehouse.products; /** * Created by michal on 08.06.2016. */ @Value public class RegisterNew { private final PaletteLabel paletteLabel;
private final List<BoxLabel> scannedBoxes;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/quality/Destroyed.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // }
import lombok.Value; import warehouse.PaletteLabel;
package warehouse.quality; /** * Created by michal on 10.08.2016. */ @Value public class Destroyed {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java import lombok.Value; import warehouse.PaletteLabel; package warehouse.quality; /** * Created by michal on 10.08.2016. */ @Value public class Destroyed {
private final PaletteLabel paletteLabel;
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/quality/QualityReportService.java
// Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java // public class EventMappings { // // private ProductStockAgentRepository stocks; // private FifoRepository fifo; // private OpsSupport support; // // public ExternalEvents externalEvents() { // return new ExternalEvents(); // } // // public ProductStock.EventsContract productStocks() { // return new ProductStocks(); // } // // @AllArgsConstructor // public class ExternalEvents { // // public void emit(Locked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Unlocked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Destroyed event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Delivered event) { // stocks.get(event.getPaletteLabel().getRefNo()) // .ifPresent(productStock -> productStock.delivered(event) // .handle((object, throwable) -> support.appliedExternalEventOnProductStock(productStock, event, throwable)) // ); // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // } // // @AllArgsConstructor // private class ProductStocks implements ProductStock.EventsContract { // // @Override // public void emit(Registered event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // // @Override // public void emit(Stored event) { // } // // @Override // public void emit(Picked event) { // } // // @Override // public void emit(Locked event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // } // // void dependencies(ProductStockAgentRepository stocks, FifoRepository fifo, OpsSupport support) { // this.stocks = stocks; // this.fifo = fifo; // this.support = support; // } // // void async(Runnable handler) { // CompletableFuture.runAsync(handler); // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockEventStore.java // public interface ProductStockEventStore { // EventId persist(PaletteLabel storageUnit, Object event); // // List<Object> readEventsInStock(String refNo); // List<Object> readEventsSince(String refNo, EventId since); // // @Value // @ToString(of = "id") // class EventId { // Object id; // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import warehouse.EventMappings; import warehouse.PaletteLabel; import warehouse.products.ProductStockEventStore; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked;
package quality; /** * Created by michal on 20.08.2016. */ public class QualityReportService { private final ProductStockEventStore stocks;
// Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java // public class EventMappings { // // private ProductStockAgentRepository stocks; // private FifoRepository fifo; // private OpsSupport support; // // public ExternalEvents externalEvents() { // return new ExternalEvents(); // } // // public ProductStock.EventsContract productStocks() { // return new ProductStocks(); // } // // @AllArgsConstructor // public class ExternalEvents { // // public void emit(Locked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Unlocked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Destroyed event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Delivered event) { // stocks.get(event.getPaletteLabel().getRefNo()) // .ifPresent(productStock -> productStock.delivered(event) // .handle((object, throwable) -> support.appliedExternalEventOnProductStock(productStock, event, throwable)) // ); // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // } // // @AllArgsConstructor // private class ProductStocks implements ProductStock.EventsContract { // // @Override // public void emit(Registered event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // // @Override // public void emit(Stored event) { // } // // @Override // public void emit(Picked event) { // } // // @Override // public void emit(Locked event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // } // // void dependencies(ProductStockAgentRepository stocks, FifoRepository fifo, OpsSupport support) { // this.stocks = stocks; // this.fifo = fifo; // this.support = support; // } // // void async(Runnable handler) { // CompletableFuture.runAsync(handler); // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockEventStore.java // public interface ProductStockEventStore { // EventId persist(PaletteLabel storageUnit, Object event); // // List<Object> readEventsInStock(String refNo); // List<Object> readEventsSince(String refNo, EventId since); // // @Value // @ToString(of = "id") // class EventId { // Object id; // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/main/java/quality/QualityReportService.java import warehouse.EventMappings; import warehouse.PaletteLabel; import warehouse.products.ProductStockEventStore; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; package quality; /** * Created by michal on 20.08.2016. */ public class QualityReportService { private final ProductStockEventStore stocks;
private final EventMappings.ExternalEvents events;
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/quality/QualityReportService.java
// Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java // public class EventMappings { // // private ProductStockAgentRepository stocks; // private FifoRepository fifo; // private OpsSupport support; // // public ExternalEvents externalEvents() { // return new ExternalEvents(); // } // // public ProductStock.EventsContract productStocks() { // return new ProductStocks(); // } // // @AllArgsConstructor // public class ExternalEvents { // // public void emit(Locked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Unlocked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Destroyed event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Delivered event) { // stocks.get(event.getPaletteLabel().getRefNo()) // .ifPresent(productStock -> productStock.delivered(event) // .handle((object, throwable) -> support.appliedExternalEventOnProductStock(productStock, event, throwable)) // ); // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // } // // @AllArgsConstructor // private class ProductStocks implements ProductStock.EventsContract { // // @Override // public void emit(Registered event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // // @Override // public void emit(Stored event) { // } // // @Override // public void emit(Picked event) { // } // // @Override // public void emit(Locked event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // } // // void dependencies(ProductStockAgentRepository stocks, FifoRepository fifo, OpsSupport support) { // this.stocks = stocks; // this.fifo = fifo; // this.support = support; // } // // void async(Runnable handler) { // CompletableFuture.runAsync(handler); // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockEventStore.java // public interface ProductStockEventStore { // EventId persist(PaletteLabel storageUnit, Object event); // // List<Object> readEventsInStock(String refNo); // List<Object> readEventsSince(String refNo, EventId since); // // @Value // @ToString(of = "id") // class EventId { // Object id; // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import warehouse.EventMappings; import warehouse.PaletteLabel; import warehouse.products.ProductStockEventStore; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked;
package quality; /** * Created by michal on 20.08.2016. */ public class QualityReportService { private final ProductStockEventStore stocks; private final EventMappings.ExternalEvents events; public QualityReportService(ProductStockEventStore stocks, EventMappings mappings) { this.stocks = stocks; this.events = mappings.externalEvents(); } public void process(QualityReport report) {
// Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java // public class EventMappings { // // private ProductStockAgentRepository stocks; // private FifoRepository fifo; // private OpsSupport support; // // public ExternalEvents externalEvents() { // return new ExternalEvents(); // } // // public ProductStock.EventsContract productStocks() { // return new ProductStocks(); // } // // @AllArgsConstructor // public class ExternalEvents { // // public void emit(Locked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Unlocked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Destroyed event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Delivered event) { // stocks.get(event.getPaletteLabel().getRefNo()) // .ifPresent(productStock -> productStock.delivered(event) // .handle((object, throwable) -> support.appliedExternalEventOnProductStock(productStock, event, throwable)) // ); // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // } // // @AllArgsConstructor // private class ProductStocks implements ProductStock.EventsContract { // // @Override // public void emit(Registered event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // // @Override // public void emit(Stored event) { // } // // @Override // public void emit(Picked event) { // } // // @Override // public void emit(Locked event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // } // // void dependencies(ProductStockAgentRepository stocks, FifoRepository fifo, OpsSupport support) { // this.stocks = stocks; // this.fifo = fifo; // this.support = support; // } // // void async(Runnable handler) { // CompletableFuture.runAsync(handler); // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockEventStore.java // public interface ProductStockEventStore { // EventId persist(PaletteLabel storageUnit, Object event); // // List<Object> readEventsInStock(String refNo); // List<Object> readEventsSince(String refNo, EventId since); // // @Value // @ToString(of = "id") // class EventId { // Object id; // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/main/java/quality/QualityReportService.java import warehouse.EventMappings; import warehouse.PaletteLabel; import warehouse.products.ProductStockEventStore; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; package quality; /** * Created by michal on 20.08.2016. */ public class QualityReportService { private final ProductStockEventStore stocks; private final EventMappings.ExternalEvents events; public QualityReportService(ProductStockEventStore stocks, EventMappings mappings) { this.stocks = stocks; this.events = mappings.externalEvents(); } public void process(QualityReport report) {
for (PaletteLabel label : report.getLocked()) {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/quality/QualityReportService.java
// Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java // public class EventMappings { // // private ProductStockAgentRepository stocks; // private FifoRepository fifo; // private OpsSupport support; // // public ExternalEvents externalEvents() { // return new ExternalEvents(); // } // // public ProductStock.EventsContract productStocks() { // return new ProductStocks(); // } // // @AllArgsConstructor // public class ExternalEvents { // // public void emit(Locked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Unlocked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Destroyed event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Delivered event) { // stocks.get(event.getPaletteLabel().getRefNo()) // .ifPresent(productStock -> productStock.delivered(event) // .handle((object, throwable) -> support.appliedExternalEventOnProductStock(productStock, event, throwable)) // ); // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // } // // @AllArgsConstructor // private class ProductStocks implements ProductStock.EventsContract { // // @Override // public void emit(Registered event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // // @Override // public void emit(Stored event) { // } // // @Override // public void emit(Picked event) { // } // // @Override // public void emit(Locked event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // } // // void dependencies(ProductStockAgentRepository stocks, FifoRepository fifo, OpsSupport support) { // this.stocks = stocks; // this.fifo = fifo; // this.support = support; // } // // void async(Runnable handler) { // CompletableFuture.runAsync(handler); // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockEventStore.java // public interface ProductStockEventStore { // EventId persist(PaletteLabel storageUnit, Object event); // // List<Object> readEventsInStock(String refNo); // List<Object> readEventsSince(String refNo, EventId since); // // @Value // @ToString(of = "id") // class EventId { // Object id; // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import warehouse.EventMappings; import warehouse.PaletteLabel; import warehouse.products.ProductStockEventStore; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked;
package quality; /** * Created by michal on 20.08.2016. */ public class QualityReportService { private final ProductStockEventStore stocks; private final EventMappings.ExternalEvents events; public QualityReportService(ProductStockEventStore stocks, EventMappings mappings) { this.stocks = stocks; this.events = mappings.externalEvents(); } public void process(QualityReport report) { for (PaletteLabel label : report.getLocked()) {
// Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java // public class EventMappings { // // private ProductStockAgentRepository stocks; // private FifoRepository fifo; // private OpsSupport support; // // public ExternalEvents externalEvents() { // return new ExternalEvents(); // } // // public ProductStock.EventsContract productStocks() { // return new ProductStocks(); // } // // @AllArgsConstructor // public class ExternalEvents { // // public void emit(Locked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Unlocked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Destroyed event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Delivered event) { // stocks.get(event.getPaletteLabel().getRefNo()) // .ifPresent(productStock -> productStock.delivered(event) // .handle((object, throwable) -> support.appliedExternalEventOnProductStock(productStock, event, throwable)) // ); // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // } // // @AllArgsConstructor // private class ProductStocks implements ProductStock.EventsContract { // // @Override // public void emit(Registered event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // // @Override // public void emit(Stored event) { // } // // @Override // public void emit(Picked event) { // } // // @Override // public void emit(Locked event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // } // // void dependencies(ProductStockAgentRepository stocks, FifoRepository fifo, OpsSupport support) { // this.stocks = stocks; // this.fifo = fifo; // this.support = support; // } // // void async(Runnable handler) { // CompletableFuture.runAsync(handler); // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockEventStore.java // public interface ProductStockEventStore { // EventId persist(PaletteLabel storageUnit, Object event); // // List<Object> readEventsInStock(String refNo); // List<Object> readEventsSince(String refNo, EventId since); // // @Value // @ToString(of = "id") // class EventId { // Object id; // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/main/java/quality/QualityReportService.java import warehouse.EventMappings; import warehouse.PaletteLabel; import warehouse.products.ProductStockEventStore; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; package quality; /** * Created by michal on 20.08.2016. */ public class QualityReportService { private final ProductStockEventStore stocks; private final EventMappings.ExternalEvents events; public QualityReportService(ProductStockEventStore stocks, EventMappings mappings) { this.stocks = stocks; this.events = mappings.externalEvents(); } public void process(QualityReport report) { for (PaletteLabel label : report.getLocked()) {
Locked event = new Locked(label);
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/quality/QualityReportService.java
// Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java // public class EventMappings { // // private ProductStockAgentRepository stocks; // private FifoRepository fifo; // private OpsSupport support; // // public ExternalEvents externalEvents() { // return new ExternalEvents(); // } // // public ProductStock.EventsContract productStocks() { // return new ProductStocks(); // } // // @AllArgsConstructor // public class ExternalEvents { // // public void emit(Locked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Unlocked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Destroyed event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Delivered event) { // stocks.get(event.getPaletteLabel().getRefNo()) // .ifPresent(productStock -> productStock.delivered(event) // .handle((object, throwable) -> support.appliedExternalEventOnProductStock(productStock, event, throwable)) // ); // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // } // // @AllArgsConstructor // private class ProductStocks implements ProductStock.EventsContract { // // @Override // public void emit(Registered event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // // @Override // public void emit(Stored event) { // } // // @Override // public void emit(Picked event) { // } // // @Override // public void emit(Locked event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // } // // void dependencies(ProductStockAgentRepository stocks, FifoRepository fifo, OpsSupport support) { // this.stocks = stocks; // this.fifo = fifo; // this.support = support; // } // // void async(Runnable handler) { // CompletableFuture.runAsync(handler); // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockEventStore.java // public interface ProductStockEventStore { // EventId persist(PaletteLabel storageUnit, Object event); // // List<Object> readEventsInStock(String refNo); // List<Object> readEventsSince(String refNo, EventId since); // // @Value // @ToString(of = "id") // class EventId { // Object id; // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import warehouse.EventMappings; import warehouse.PaletteLabel; import warehouse.products.ProductStockEventStore; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked;
package quality; /** * Created by michal on 20.08.2016. */ public class QualityReportService { private final ProductStockEventStore stocks; private final EventMappings.ExternalEvents events; public QualityReportService(ProductStockEventStore stocks, EventMappings mappings) { this.stocks = stocks; this.events = mappings.externalEvents(); } public void process(QualityReport report) { for (PaletteLabel label : report.getLocked()) { Locked event = new Locked(label); stocks.persist(label, event); events.emit(event); } for (QualityReport.Recovered status : report.getRecovered()) {
// Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java // public class EventMappings { // // private ProductStockAgentRepository stocks; // private FifoRepository fifo; // private OpsSupport support; // // public ExternalEvents externalEvents() { // return new ExternalEvents(); // } // // public ProductStock.EventsContract productStocks() { // return new ProductStocks(); // } // // @AllArgsConstructor // public class ExternalEvents { // // public void emit(Locked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Unlocked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Destroyed event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Delivered event) { // stocks.get(event.getPaletteLabel().getRefNo()) // .ifPresent(productStock -> productStock.delivered(event) // .handle((object, throwable) -> support.appliedExternalEventOnProductStock(productStock, event, throwable)) // ); // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // } // // @AllArgsConstructor // private class ProductStocks implements ProductStock.EventsContract { // // @Override // public void emit(Registered event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // // @Override // public void emit(Stored event) { // } // // @Override // public void emit(Picked event) { // } // // @Override // public void emit(Locked event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // } // // void dependencies(ProductStockAgentRepository stocks, FifoRepository fifo, OpsSupport support) { // this.stocks = stocks; // this.fifo = fifo; // this.support = support; // } // // void async(Runnable handler) { // CompletableFuture.runAsync(handler); // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockEventStore.java // public interface ProductStockEventStore { // EventId persist(PaletteLabel storageUnit, Object event); // // List<Object> readEventsInStock(String refNo); // List<Object> readEventsSince(String refNo, EventId since); // // @Value // @ToString(of = "id") // class EventId { // Object id; // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/main/java/quality/QualityReportService.java import warehouse.EventMappings; import warehouse.PaletteLabel; import warehouse.products.ProductStockEventStore; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; package quality; /** * Created by michal on 20.08.2016. */ public class QualityReportService { private final ProductStockEventStore stocks; private final EventMappings.ExternalEvents events; public QualityReportService(ProductStockEventStore stocks, EventMappings mappings) { this.stocks = stocks; this.events = mappings.externalEvents(); } public void process(QualityReport report) { for (PaletteLabel label : report.getLocked()) { Locked event = new Locked(label); stocks.persist(label, event); events.emit(event); } for (QualityReport.Recovered status : report.getRecovered()) {
Unlocked event = new Unlocked(status.getLabel(), status.getRecovered(), status.getScraped());
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/quality/QualityReportService.java
// Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java // public class EventMappings { // // private ProductStockAgentRepository stocks; // private FifoRepository fifo; // private OpsSupport support; // // public ExternalEvents externalEvents() { // return new ExternalEvents(); // } // // public ProductStock.EventsContract productStocks() { // return new ProductStocks(); // } // // @AllArgsConstructor // public class ExternalEvents { // // public void emit(Locked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Unlocked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Destroyed event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Delivered event) { // stocks.get(event.getPaletteLabel().getRefNo()) // .ifPresent(productStock -> productStock.delivered(event) // .handle((object, throwable) -> support.appliedExternalEventOnProductStock(productStock, event, throwable)) // ); // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // } // // @AllArgsConstructor // private class ProductStocks implements ProductStock.EventsContract { // // @Override // public void emit(Registered event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // // @Override // public void emit(Stored event) { // } // // @Override // public void emit(Picked event) { // } // // @Override // public void emit(Locked event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // } // // void dependencies(ProductStockAgentRepository stocks, FifoRepository fifo, OpsSupport support) { // this.stocks = stocks; // this.fifo = fifo; // this.support = support; // } // // void async(Runnable handler) { // CompletableFuture.runAsync(handler); // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockEventStore.java // public interface ProductStockEventStore { // EventId persist(PaletteLabel storageUnit, Object event); // // List<Object> readEventsInStock(String refNo); // List<Object> readEventsSince(String refNo, EventId since); // // @Value // @ToString(of = "id") // class EventId { // Object id; // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import warehouse.EventMappings; import warehouse.PaletteLabel; import warehouse.products.ProductStockEventStore; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked;
package quality; /** * Created by michal on 20.08.2016. */ public class QualityReportService { private final ProductStockEventStore stocks; private final EventMappings.ExternalEvents events; public QualityReportService(ProductStockEventStore stocks, EventMappings mappings) { this.stocks = stocks; this.events = mappings.externalEvents(); } public void process(QualityReport report) { for (PaletteLabel label : report.getLocked()) { Locked event = new Locked(label); stocks.persist(label, event); events.emit(event); } for (QualityReport.Recovered status : report.getRecovered()) { Unlocked event = new Unlocked(status.getLabel(), status.getRecovered(), status.getScraped()); stocks.persist(status.getLabel(), event); events.emit(event); } for (PaletteLabel label : report.getDestroyed()) {
// Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java // public class EventMappings { // // private ProductStockAgentRepository stocks; // private FifoRepository fifo; // private OpsSupport support; // // public ExternalEvents externalEvents() { // return new ExternalEvents(); // } // // public ProductStock.EventsContract productStocks() { // return new ProductStocks(); // } // // @AllArgsConstructor // public class ExternalEvents { // // public void emit(Locked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Unlocked event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Destroyed event) { // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // // public void emit(Delivered event) { // stocks.get(event.getPaletteLabel().getRefNo()) // .ifPresent(productStock -> productStock.delivered(event) // .handle((object, throwable) -> support.appliedExternalEventOnProductStock(productStock, event, throwable)) // ); // fifo.handle(event.getPaletteLabel().getRefNo(), event); // } // } // // @AllArgsConstructor // private class ProductStocks implements ProductStock.EventsContract { // // @Override // public void emit(Registered event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // // @Override // public void emit(Stored event) { // } // // @Override // public void emit(Picked event) { // } // // @Override // public void emit(Locked event) { // async(() -> fifo.handle(event.getPaletteLabel().getRefNo(), event)); // } // } // // void dependencies(ProductStockAgentRepository stocks, FifoRepository fifo, OpsSupport support) { // this.stocks = stocks; // this.fifo = fifo; // this.support = support; // } // // void async(Runnable handler) { // CompletableFuture.runAsync(handler); // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockEventStore.java // public interface ProductStockEventStore { // EventId persist(PaletteLabel storageUnit, Object event); // // List<Object> readEventsInStock(String refNo); // List<Object> readEventsSince(String refNo, EventId since); // // @Value // @ToString(of = "id") // class EventId { // Object id; // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/main/java/quality/QualityReportService.java import warehouse.EventMappings; import warehouse.PaletteLabel; import warehouse.products.ProductStockEventStore; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; package quality; /** * Created by michal on 20.08.2016. */ public class QualityReportService { private final ProductStockEventStore stocks; private final EventMappings.ExternalEvents events; public QualityReportService(ProductStockEventStore stocks, EventMappings mappings) { this.stocks = stocks; this.events = mappings.externalEvents(); } public void process(QualityReport report) { for (PaletteLabel label : report.getLocked()) { Locked event = new Locked(label); stocks.persist(label, event); events.emit(event); } for (QualityReport.Recovered status : report.getRecovered()) { Unlocked event = new Unlocked(status.getLabel(), status.getRecovered(), status.getScraped()); stocks.persist(status.getLabel(), event); events.emit(event); } for (PaletteLabel label : report.getDestroyed()) {
Destroyed event = new Destroyed(label);
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/warehouse/products/ProductStockSql2oEventsStore.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/Persistence.java // public class Persistence { // // public static final ObjectMapper mapper = new ObjectMapper() // .setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE) // .setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE) // .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY) // .setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY) // .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) // .enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID) // .registerModule(new Jdk8Module()) // .registerModule(new ParameterNamesModule()) // .registerModule(new JavaTimeModule()); // // public static final SerializationVersioning serialization = new SerializationVersioning( // current(Registered.class, "ReadyToStore v1", mapper::writeValueAsString, mapper::readValue), // current(Stored.class, "Stored v1", mapper::writeValueAsString, mapper::readValue), // current(Picked.class, "Picked v2", mapper::writeValueAsString, mapper::readValue), // obsolete(Picked.class, "Picked v1", Persistence::pickedFromV1), // current(Locked.class, "Locked v1", mapper::writeValueAsString, mapper::readValue), // current(Unlocked.class, "Unlocked v1", mapper::writeValueAsString, mapper::readValue), // current(Destroyed.class, "Destroyed v1", mapper::writeValueAsString, mapper::readValue) // ); // // private static Picked pickedFromV1(String string, Class<Picked> type) throws Throwable { // JsonNode json = mapper.readTree(string); // return new Picked( // new PaletteLabel( // json.path("paletteLabel").path("id").asText(), // json.path("paletteLabel").path("refNo").asText() // ), // json.path("user").asText(), // new Location(json.path("lastKnownLocation").path("location").asText()), // Location.onTheMove(json.path("user").asText()) // ); // } // // private Persistence() { // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // }
import lombok.AllArgsConstructor; import lombok.Data; import org.sql2o.Connection; import org.sql2o.Query; import org.sql2o.ResultSetIterable; import org.sql2o.Sql2o; import warehouse.PaletteLabel; import warehouse.Persistence; import warehouse.quality.Destroyed; import java.time.Instant; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.StreamSupport;
package warehouse.products; /** * Created by michal on 21.10.2017. */ @AllArgsConstructor public class ProductStockSql2oEventsStore implements ProductStockEventStore { private final Sql2o sql2o; private final Predicate<Object> archiveUnit =
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/Persistence.java // public class Persistence { // // public static final ObjectMapper mapper = new ObjectMapper() // .setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE) // .setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE) // .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY) // .setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY) // .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) // .enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID) // .registerModule(new Jdk8Module()) // .registerModule(new ParameterNamesModule()) // .registerModule(new JavaTimeModule()); // // public static final SerializationVersioning serialization = new SerializationVersioning( // current(Registered.class, "ReadyToStore v1", mapper::writeValueAsString, mapper::readValue), // current(Stored.class, "Stored v1", mapper::writeValueAsString, mapper::readValue), // current(Picked.class, "Picked v2", mapper::writeValueAsString, mapper::readValue), // obsolete(Picked.class, "Picked v1", Persistence::pickedFromV1), // current(Locked.class, "Locked v1", mapper::writeValueAsString, mapper::readValue), // current(Unlocked.class, "Unlocked v1", mapper::writeValueAsString, mapper::readValue), // current(Destroyed.class, "Destroyed v1", mapper::writeValueAsString, mapper::readValue) // ); // // private static Picked pickedFromV1(String string, Class<Picked> type) throws Throwable { // JsonNode json = mapper.readTree(string); // return new Picked( // new PaletteLabel( // json.path("paletteLabel").path("id").asText(), // json.path("paletteLabel").path("refNo").asText() // ), // json.path("user").asText(), // new Location(json.path("lastKnownLocation").path("location").asText()), // Location.onTheMove(json.path("user").asText()) // ); // } // // private Persistence() { // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockSql2oEventsStore.java import lombok.AllArgsConstructor; import lombok.Data; import org.sql2o.Connection; import org.sql2o.Query; import org.sql2o.ResultSetIterable; import org.sql2o.Sql2o; import warehouse.PaletteLabel; import warehouse.Persistence; import warehouse.quality.Destroyed; import java.time.Instant; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.StreamSupport; package warehouse.products; /** * Created by michal on 21.10.2017. */ @AllArgsConstructor public class ProductStockSql2oEventsStore implements ProductStockEventStore { private final Sql2o sql2o; private final Predicate<Object> archiveUnit =
event -> event instanceof Destroyed ||
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/warehouse/products/ProductStockSql2oEventsStore.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/Persistence.java // public class Persistence { // // public static final ObjectMapper mapper = new ObjectMapper() // .setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE) // .setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE) // .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY) // .setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY) // .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) // .enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID) // .registerModule(new Jdk8Module()) // .registerModule(new ParameterNamesModule()) // .registerModule(new JavaTimeModule()); // // public static final SerializationVersioning serialization = new SerializationVersioning( // current(Registered.class, "ReadyToStore v1", mapper::writeValueAsString, mapper::readValue), // current(Stored.class, "Stored v1", mapper::writeValueAsString, mapper::readValue), // current(Picked.class, "Picked v2", mapper::writeValueAsString, mapper::readValue), // obsolete(Picked.class, "Picked v1", Persistence::pickedFromV1), // current(Locked.class, "Locked v1", mapper::writeValueAsString, mapper::readValue), // current(Unlocked.class, "Unlocked v1", mapper::writeValueAsString, mapper::readValue), // current(Destroyed.class, "Destroyed v1", mapper::writeValueAsString, mapper::readValue) // ); // // private static Picked pickedFromV1(String string, Class<Picked> type) throws Throwable { // JsonNode json = mapper.readTree(string); // return new Picked( // new PaletteLabel( // json.path("paletteLabel").path("id").asText(), // json.path("paletteLabel").path("refNo").asText() // ), // json.path("user").asText(), // new Location(json.path("lastKnownLocation").path("location").asText()), // Location.onTheMove(json.path("user").asText()) // ); // } // // private Persistence() { // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // }
import lombok.AllArgsConstructor; import lombok.Data; import org.sql2o.Connection; import org.sql2o.Query; import org.sql2o.ResultSetIterable; import org.sql2o.Sql2o; import warehouse.PaletteLabel; import warehouse.Persistence; import warehouse.quality.Destroyed; import java.time.Instant; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.StreamSupport;
package warehouse.products; /** * Created by michal on 21.10.2017. */ @AllArgsConstructor public class ProductStockSql2oEventsStore implements ProductStockEventStore { private final Sql2o sql2o; private final Predicate<Object> archiveUnit = event -> event instanceof Destroyed || event instanceof Delivered; @Data private static class ProductStockHistoryEvent { private final long id; private final Instant created; private final String refNo; private final String unit; private final String type; private final String content; private final boolean inStock; } @Override
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/Persistence.java // public class Persistence { // // public static final ObjectMapper mapper = new ObjectMapper() // .setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE) // .setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE) // .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY) // .setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY) // .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) // .enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID) // .registerModule(new Jdk8Module()) // .registerModule(new ParameterNamesModule()) // .registerModule(new JavaTimeModule()); // // public static final SerializationVersioning serialization = new SerializationVersioning( // current(Registered.class, "ReadyToStore v1", mapper::writeValueAsString, mapper::readValue), // current(Stored.class, "Stored v1", mapper::writeValueAsString, mapper::readValue), // current(Picked.class, "Picked v2", mapper::writeValueAsString, mapper::readValue), // obsolete(Picked.class, "Picked v1", Persistence::pickedFromV1), // current(Locked.class, "Locked v1", mapper::writeValueAsString, mapper::readValue), // current(Unlocked.class, "Unlocked v1", mapper::writeValueAsString, mapper::readValue), // current(Destroyed.class, "Destroyed v1", mapper::writeValueAsString, mapper::readValue) // ); // // private static Picked pickedFromV1(String string, Class<Picked> type) throws Throwable { // JsonNode json = mapper.readTree(string); // return new Picked( // new PaletteLabel( // json.path("paletteLabel").path("id").asText(), // json.path("paletteLabel").path("refNo").asText() // ), // json.path("user").asText(), // new Location(json.path("lastKnownLocation").path("location").asText()), // Location.onTheMove(json.path("user").asText()) // ); // } // // private Persistence() { // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockSql2oEventsStore.java import lombok.AllArgsConstructor; import lombok.Data; import org.sql2o.Connection; import org.sql2o.Query; import org.sql2o.ResultSetIterable; import org.sql2o.Sql2o; import warehouse.PaletteLabel; import warehouse.Persistence; import warehouse.quality.Destroyed; import java.time.Instant; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.StreamSupport; package warehouse.products; /** * Created by michal on 21.10.2017. */ @AllArgsConstructor public class ProductStockSql2oEventsStore implements ProductStockEventStore { private final Sql2o sql2o; private final Predicate<Object> archiveUnit = event -> event instanceof Destroyed || event instanceof Delivered; @Data private static class ProductStockHistoryEvent { private final long id; private final Instant created; private final String refNo; private final String unit; private final String type; private final String content; private final boolean inStock; } @Override
public EventId persist(PaletteLabel storageUnit, Object event) {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/warehouse/products/ProductStockSql2oEventsStore.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/Persistence.java // public class Persistence { // // public static final ObjectMapper mapper = new ObjectMapper() // .setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE) // .setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE) // .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY) // .setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY) // .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) // .enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID) // .registerModule(new Jdk8Module()) // .registerModule(new ParameterNamesModule()) // .registerModule(new JavaTimeModule()); // // public static final SerializationVersioning serialization = new SerializationVersioning( // current(Registered.class, "ReadyToStore v1", mapper::writeValueAsString, mapper::readValue), // current(Stored.class, "Stored v1", mapper::writeValueAsString, mapper::readValue), // current(Picked.class, "Picked v2", mapper::writeValueAsString, mapper::readValue), // obsolete(Picked.class, "Picked v1", Persistence::pickedFromV1), // current(Locked.class, "Locked v1", mapper::writeValueAsString, mapper::readValue), // current(Unlocked.class, "Unlocked v1", mapper::writeValueAsString, mapper::readValue), // current(Destroyed.class, "Destroyed v1", mapper::writeValueAsString, mapper::readValue) // ); // // private static Picked pickedFromV1(String string, Class<Picked> type) throws Throwable { // JsonNode json = mapper.readTree(string); // return new Picked( // new PaletteLabel( // json.path("paletteLabel").path("id").asText(), // json.path("paletteLabel").path("refNo").asText() // ), // json.path("user").asText(), // new Location(json.path("lastKnownLocation").path("location").asText()), // Location.onTheMove(json.path("user").asText()) // ); // } // // private Persistence() { // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // }
import lombok.AllArgsConstructor; import lombok.Data; import org.sql2o.Connection; import org.sql2o.Query; import org.sql2o.ResultSetIterable; import org.sql2o.Sql2o; import warehouse.PaletteLabel; import warehouse.Persistence; import warehouse.quality.Destroyed; import java.time.Instant; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.StreamSupport;
package warehouse.products; /** * Created by michal on 21.10.2017. */ @AllArgsConstructor public class ProductStockSql2oEventsStore implements ProductStockEventStore { private final Sql2o sql2o; private final Predicate<Object> archiveUnit = event -> event instanceof Destroyed || event instanceof Delivered; @Data private static class ProductStockHistoryEvent { private final long id; private final Instant created; private final String refNo; private final String unit; private final String type; private final String content; private final boolean inStock; } @Override public EventId persist(PaletteLabel storageUnit, Object event) {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-infrastructure/src/main/java/warehouse/Persistence.java // public class Persistence { // // public static final ObjectMapper mapper = new ObjectMapper() // .setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE) // .setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE) // .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY) // .setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY) // .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) // .enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID) // .registerModule(new Jdk8Module()) // .registerModule(new ParameterNamesModule()) // .registerModule(new JavaTimeModule()); // // public static final SerializationVersioning serialization = new SerializationVersioning( // current(Registered.class, "ReadyToStore v1", mapper::writeValueAsString, mapper::readValue), // current(Stored.class, "Stored v1", mapper::writeValueAsString, mapper::readValue), // current(Picked.class, "Picked v2", mapper::writeValueAsString, mapper::readValue), // obsolete(Picked.class, "Picked v1", Persistence::pickedFromV1), // current(Locked.class, "Locked v1", mapper::writeValueAsString, mapper::readValue), // current(Unlocked.class, "Unlocked v1", mapper::writeValueAsString, mapper::readValue), // current(Destroyed.class, "Destroyed v1", mapper::writeValueAsString, mapper::readValue) // ); // // private static Picked pickedFromV1(String string, Class<Picked> type) throws Throwable { // JsonNode json = mapper.readTree(string); // return new Picked( // new PaletteLabel( // json.path("paletteLabel").path("id").asText(), // json.path("paletteLabel").path("refNo").asText() // ), // json.path("user").asText(), // new Location(json.path("lastKnownLocation").path("location").asText()), // Location.onTheMove(json.path("user").asText()) // ); // } // // private Persistence() { // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockSql2oEventsStore.java import lombok.AllArgsConstructor; import lombok.Data; import org.sql2o.Connection; import org.sql2o.Query; import org.sql2o.ResultSetIterable; import org.sql2o.Sql2o; import warehouse.PaletteLabel; import warehouse.Persistence; import warehouse.quality.Destroyed; import java.time.Instant; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.StreamSupport; package warehouse.products; /** * Created by michal on 21.10.2017. */ @AllArgsConstructor public class ProductStockSql2oEventsStore implements ProductStockEventStore { private final Sql2o sql2o; private final Predicate<Object> archiveUnit = event -> event instanceof Destroyed || event instanceof Delivered; @Data private static class ProductStockHistoryEvent { private final long id; private final Instant created; private final String refNo; private final String unit; private final String type; private final String content; private final boolean inStock; } @Override public EventId persist(PaletteLabel storageUnit, Object event) {
String json = Persistence.serialization.serialize(event);
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/quality/QualityReport.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // }
import lombok.Value; import warehouse.PaletteLabel; import java.util.List;
package quality; /** * Created by michal on 18.08.2016. */ @Value public class QualityReport {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // Path: warehouse-infrastructure/src/main/java/quality/QualityReport.java import lombok.Value; import warehouse.PaletteLabel; import java.util.List; package quality; /** * Created by michal on 18.08.2016. */ @Value public class QualityReport {
private final List<PaletteLabel> locked;
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/test/java/tools/MultiMethodTest.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import org.assertj.core.api.Assertions; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import warehouse.PaletteLabel; import warehouse.products.Delivered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.lang.invoke.MethodHandles; import static org.hamcrest.core.IsInstanceOf.instanceOf;
package tools; /** * Created by michal on 15.08.2016. */ public class MultiMethodTest { public class HandlerOfManyEvents {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/test/java/tools/MultiMethodTest.java import org.assertj.core.api.Assertions; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import warehouse.PaletteLabel; import warehouse.products.Delivered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.lang.invoke.MethodHandles; import static org.hamcrest.core.IsInstanceOf.instanceOf; package tools; /** * Created by michal on 15.08.2016. */ public class MultiMethodTest { public class HandlerOfManyEvents {
public void apply(Locked event) {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/test/java/tools/MultiMethodTest.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import org.assertj.core.api.Assertions; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import warehouse.PaletteLabel; import warehouse.products.Delivered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.lang.invoke.MethodHandles; import static org.hamcrest.core.IsInstanceOf.instanceOf;
package tools; /** * Created by michal on 15.08.2016. */ public class MultiMethodTest { public class HandlerOfManyEvents { public void apply(Locked event) { wasCalled = true; }
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/test/java/tools/MultiMethodTest.java import org.assertj.core.api.Assertions; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import warehouse.PaletteLabel; import warehouse.products.Delivered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.lang.invoke.MethodHandles; import static org.hamcrest.core.IsInstanceOf.instanceOf; package tools; /** * Created by michal on 15.08.2016. */ public class MultiMethodTest { public class HandlerOfManyEvents { public void apply(Locked event) { wasCalled = true; }
protected void apply(Delivered event) {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/test/java/tools/MultiMethodTest.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import org.assertj.core.api.Assertions; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import warehouse.PaletteLabel; import warehouse.products.Delivered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.lang.invoke.MethodHandles; import static org.hamcrest.core.IsInstanceOf.instanceOf;
package tools; /** * Created by michal on 15.08.2016. */ public class MultiMethodTest { public class HandlerOfManyEvents { public void apply(Locked event) { wasCalled = true; } protected void apply(Delivered event) { wasCalledProtected = true; }
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/test/java/tools/MultiMethodTest.java import org.assertj.core.api.Assertions; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import warehouse.PaletteLabel; import warehouse.products.Delivered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.lang.invoke.MethodHandles; import static org.hamcrest.core.IsInstanceOf.instanceOf; package tools; /** * Created by michal on 15.08.2016. */ public class MultiMethodTest { public class HandlerOfManyEvents { public void apply(Locked event) { wasCalled = true; } protected void apply(Delivered event) { wasCalledProtected = true; }
private void apply(Unlocked event) {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/test/java/tools/MultiMethodTest.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import org.assertj.core.api.Assertions; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import warehouse.PaletteLabel; import warehouse.products.Delivered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.lang.invoke.MethodHandles; import static org.hamcrest.core.IsInstanceOf.instanceOf;
package tools; /** * Created by michal on 15.08.2016. */ public class MultiMethodTest { public class HandlerOfManyEvents { public void apply(Locked event) { wasCalled = true; } protected void apply(Delivered event) { wasCalledProtected = true; } private void apply(Unlocked event) { // don't expect it to work }
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/test/java/tools/MultiMethodTest.java import org.assertj.core.api.Assertions; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import warehouse.PaletteLabel; import warehouse.products.Delivered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.lang.invoke.MethodHandles; import static org.hamcrest.core.IsInstanceOf.instanceOf; package tools; /** * Created by michal on 15.08.2016. */ public class MultiMethodTest { public class HandlerOfManyEvents { public void apply(Locked event) { wasCalled = true; } protected void apply(Delivered event) { wasCalledProtected = true; } private void apply(Unlocked event) { // don't expect it to work }
public void apply(Destroyed event) throws Exception {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/test/java/tools/MultiMethodTest.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import org.assertj.core.api.Assertions; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import warehouse.PaletteLabel; import warehouse.products.Delivered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.lang.invoke.MethodHandles; import static org.hamcrest.core.IsInstanceOf.instanceOf;
@Test public void silentOnPrivateCall() throws Throwable { HandlerOfManyEvents object = new HandlerOfManyEvents(); handler.call(object, new Unlocked(null, 0, 0)); } @Test public void missingHandlerOnPrivateCall() throws Throwable { thrown.expectCause(instanceOf(IllegalAccessException.class)); handler .onMissingHandler(e -> { throw new RuntimeException(e); }); HandlerOfManyEvents object = new HandlerOfManyEvents(); handler.call(object, new Unlocked(null, 0, 0)); } @Test public void multimethodThrowingCall() throws Throwable { thrown.expect(BusinessException.class); HandlerOfManyEvents object = new HandlerOfManyEvents(); handler.call(object, new Destroyed(null)); } @Test public void silentOnMissingCall() throws Throwable { HandlerOfManyEvents object = new HandlerOfManyEvents();
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/test/java/tools/MultiMethodTest.java import org.assertj.core.api.Assertions; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import warehouse.PaletteLabel; import warehouse.products.Delivered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.lang.invoke.MethodHandles; import static org.hamcrest.core.IsInstanceOf.instanceOf; @Test public void silentOnPrivateCall() throws Throwable { HandlerOfManyEvents object = new HandlerOfManyEvents(); handler.call(object, new Unlocked(null, 0, 0)); } @Test public void missingHandlerOnPrivateCall() throws Throwable { thrown.expectCause(instanceOf(IllegalAccessException.class)); handler .onMissingHandler(e -> { throw new RuntimeException(e); }); HandlerOfManyEvents object = new HandlerOfManyEvents(); handler.call(object, new Unlocked(null, 0, 0)); } @Test public void multimethodThrowingCall() throws Throwable { thrown.expect(BusinessException.class); HandlerOfManyEvents object = new HandlerOfManyEvents(); handler.call(object, new Destroyed(null)); } @Test public void silentOnMissingCall() throws Throwable { HandlerOfManyEvents object = new HandlerOfManyEvents();
handler.call(object, new PaletteLabel("", ""));
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/picklist/Fifo.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors;
package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @AllArgsConstructor public class Fifo { public interface PaletteLocations {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/main/java/warehouse/picklist/Fifo.java import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @AllArgsConstructor public class Fifo { public interface PaletteLocations {
Location locationOf(PaletteLabel paletteLabel);
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/picklist/Fifo.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors;
package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @AllArgsConstructor public class Fifo { public interface PaletteLocations {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/main/java/warehouse/picklist/Fifo.java import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; package warehouse.picklist; /** * Created by michal on 15.07.2016. */ @AllArgsConstructor public class Fifo { public interface PaletteLocations {
Location locationOf(PaletteLabel paletteLabel);
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/picklist/Fifo.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors;
} private final PaletteLocations locations; private final Products products; public PickList pickList(Order order) { PickList.PickListBuilder pickList = PickList.builder(); for (Order.Item item : order.getItems()) { products.product(item.getRefNo()) .first(item.getAmount()).forEach(paletteInfo -> pickList.add(paletteInfo.paletteLabel, locations.locationOf(paletteInfo.paletteLabel))); } return pickList.build(); } protected static class PerProduct { private final SortedSet<PaletteInfo> queue = new TreeSet<>( Comparator.comparing(PaletteInfo::getReadyAt) .thenComparing(p -> p.getPaletteLabel().getId()) ); private final Map<PaletteLabel, PaletteInfo> index = new HashMap<>(); private List<PaletteInfo> first(int amount) { return queue.stream() .filter(PaletteInfo::isAvailable) .limit(amount).collect(Collectors.toList()); }
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/main/java/warehouse/picklist/Fifo.java import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; } private final PaletteLocations locations; private final Products products; public PickList pickList(Order order) { PickList.PickListBuilder pickList = PickList.builder(); for (Order.Item item : order.getItems()) { products.product(item.getRefNo()) .first(item.getAmount()).forEach(paletteInfo -> pickList.add(paletteInfo.paletteLabel, locations.locationOf(paletteInfo.paletteLabel))); } return pickList.build(); } protected static class PerProduct { private final SortedSet<PaletteInfo> queue = new TreeSet<>( Comparator.comparing(PaletteInfo::getReadyAt) .thenComparing(p -> p.getPaletteLabel().getId()) ); private final Map<PaletteLabel, PaletteInfo> index = new HashMap<>(); private List<PaletteInfo> first(int amount) { return queue.stream() .filter(PaletteInfo::isAvailable) .limit(amount).collect(Collectors.toList()); }
protected void apply(Registered event) {
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/picklist/Fifo.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors;
public PickList pickList(Order order) { PickList.PickListBuilder pickList = PickList.builder(); for (Order.Item item : order.getItems()) { products.product(item.getRefNo()) .first(item.getAmount()).forEach(paletteInfo -> pickList.add(paletteInfo.paletteLabel, locations.locationOf(paletteInfo.paletteLabel))); } return pickList.build(); } protected static class PerProduct { private final SortedSet<PaletteInfo> queue = new TreeSet<>( Comparator.comparing(PaletteInfo::getReadyAt) .thenComparing(p -> p.getPaletteLabel().getId()) ); private final Map<PaletteLabel, PaletteInfo> index = new HashMap<>(); private List<PaletteInfo> first(int amount) { return queue.stream() .filter(PaletteInfo::isAvailable) .limit(amount).collect(Collectors.toList()); } protected void apply(Registered event) { add(new PaletteInfo(event.getPaletteLabel(), event.getReadyAt())); }
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/main/java/warehouse/picklist/Fifo.java import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; public PickList pickList(Order order) { PickList.PickListBuilder pickList = PickList.builder(); for (Order.Item item : order.getItems()) { products.product(item.getRefNo()) .first(item.getAmount()).forEach(paletteInfo -> pickList.add(paletteInfo.paletteLabel, locations.locationOf(paletteInfo.paletteLabel))); } return pickList.build(); } protected static class PerProduct { private final SortedSet<PaletteInfo> queue = new TreeSet<>( Comparator.comparing(PaletteInfo::getReadyAt) .thenComparing(p -> p.getPaletteLabel().getId()) ); private final Map<PaletteLabel, PaletteInfo> index = new HashMap<>(); private List<PaletteInfo> first(int amount) { return queue.stream() .filter(PaletteInfo::isAvailable) .limit(amount).collect(Collectors.toList()); } protected void apply(Registered event) { add(new PaletteInfo(event.getPaletteLabel(), event.getReadyAt())); }
protected void apply(Locked event) {
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/picklist/Fifo.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors;
products.product(item.getRefNo()) .first(item.getAmount()).forEach(paletteInfo -> pickList.add(paletteInfo.paletteLabel, locations.locationOf(paletteInfo.paletteLabel))); } return pickList.build(); } protected static class PerProduct { private final SortedSet<PaletteInfo> queue = new TreeSet<>( Comparator.comparing(PaletteInfo::getReadyAt) .thenComparing(p -> p.getPaletteLabel().getId()) ); private final Map<PaletteLabel, PaletteInfo> index = new HashMap<>(); private List<PaletteInfo> first(int amount) { return queue.stream() .filter(PaletteInfo::isAvailable) .limit(amount).collect(Collectors.toList()); } protected void apply(Registered event) { add(new PaletteInfo(event.getPaletteLabel(), event.getReadyAt())); } protected void apply(Locked event) { available(event.getPaletteLabel(), false); }
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/main/java/warehouse/picklist/Fifo.java import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; products.product(item.getRefNo()) .first(item.getAmount()).forEach(paletteInfo -> pickList.add(paletteInfo.paletteLabel, locations.locationOf(paletteInfo.paletteLabel))); } return pickList.build(); } protected static class PerProduct { private final SortedSet<PaletteInfo> queue = new TreeSet<>( Comparator.comparing(PaletteInfo::getReadyAt) .thenComparing(p -> p.getPaletteLabel().getId()) ); private final Map<PaletteLabel, PaletteInfo> index = new HashMap<>(); private List<PaletteInfo> first(int amount) { return queue.stream() .filter(PaletteInfo::isAvailable) .limit(amount).collect(Collectors.toList()); } protected void apply(Registered event) { add(new PaletteInfo(event.getPaletteLabel(), event.getReadyAt())); } protected void apply(Locked event) { available(event.getPaletteLabel(), false); }
protected void apply(Unlocked event) {
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/picklist/Fifo.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors;
} return pickList.build(); } protected static class PerProduct { private final SortedSet<PaletteInfo> queue = new TreeSet<>( Comparator.comparing(PaletteInfo::getReadyAt) .thenComparing(p -> p.getPaletteLabel().getId()) ); private final Map<PaletteLabel, PaletteInfo> index = new HashMap<>(); private List<PaletteInfo> first(int amount) { return queue.stream() .filter(PaletteInfo::isAvailable) .limit(amount).collect(Collectors.toList()); } protected void apply(Registered event) { add(new PaletteInfo(event.getPaletteLabel(), event.getReadyAt())); } protected void apply(Locked event) { available(event.getPaletteLabel(), false); } protected void apply(Unlocked event) { available(event.getPaletteLabel(), true); }
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/main/java/warehouse/picklist/Fifo.java import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; } return pickList.build(); } protected static class PerProduct { private final SortedSet<PaletteInfo> queue = new TreeSet<>( Comparator.comparing(PaletteInfo::getReadyAt) .thenComparing(p -> p.getPaletteLabel().getId()) ); private final Map<PaletteLabel, PaletteInfo> index = new HashMap<>(); private List<PaletteInfo> first(int amount) { return queue.stream() .filter(PaletteInfo::isAvailable) .limit(amount).collect(Collectors.toList()); } protected void apply(Registered event) { add(new PaletteInfo(event.getPaletteLabel(), event.getReadyAt())); } protected void apply(Locked event) { available(event.getPaletteLabel(), false); } protected void apply(Unlocked event) { available(event.getPaletteLabel(), true); }
protected void apply(Delivered event) {
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/picklist/Fifo.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors;
protected static class PerProduct { private final SortedSet<PaletteInfo> queue = new TreeSet<>( Comparator.comparing(PaletteInfo::getReadyAt) .thenComparing(p -> p.getPaletteLabel().getId()) ); private final Map<PaletteLabel, PaletteInfo> index = new HashMap<>(); private List<PaletteInfo> first(int amount) { return queue.stream() .filter(PaletteInfo::isAvailable) .limit(amount).collect(Collectors.toList()); } protected void apply(Registered event) { add(new PaletteInfo(event.getPaletteLabel(), event.getReadyAt())); } protected void apply(Locked event) { available(event.getPaletteLabel(), false); } protected void apply(Unlocked event) { available(event.getPaletteLabel(), true); } protected void apply(Delivered event) { remove(event.getPaletteLabel()); }
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java // @Value // public class Delivered { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/products/Registered.java // @Value // @AllArgsConstructor // public class Registered { // private final PaletteLabel paletteLabel; // private final List<BoxLabel> scannedBoxes; // private final LocalDateTime readyAt; // private final Location preferredLocation; // private final ValidationResult validationResult; // // public Registered(PaletteLabel paletteLabel, List<BoxLabel> scannedBoxes, // LocalDateTime readyAt, Location preferredLocation) { // this.paletteLabel = paletteLabel; // this.scannedBoxes = Collections.unmodifiableList(scannedBoxes); // this.readyAt = readyAt; // this.preferredLocation = preferredLocation; // validationResult = valid(); // } // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-model/src/main/java/warehouse/picklist/Fifo.java import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.products.Delivered; import warehouse.products.Registered; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; protected static class PerProduct { private final SortedSet<PaletteInfo> queue = new TreeSet<>( Comparator.comparing(PaletteInfo::getReadyAt) .thenComparing(p -> p.getPaletteLabel().getId()) ); private final Map<PaletteLabel, PaletteInfo> index = new HashMap<>(); private List<PaletteInfo> first(int amount) { return queue.stream() .filter(PaletteInfo::isAvailable) .limit(amount).collect(Collectors.toList()); } protected void apply(Registered event) { add(new PaletteInfo(event.getPaletteLabel(), event.getReadyAt())); } protected void apply(Locked event) { available(event.getPaletteLabel(), false); } protected void apply(Unlocked event) { available(event.getPaletteLabel(), true); } protected void apply(Delivered event) { remove(event.getPaletteLabel()); }
protected void apply(Destroyed event) {
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/products/EventsAssert.java
// Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // }
import org.assertj.core.api.AbstractObjectAssert; import org.assertj.core.api.Assertions; import org.mockito.Mockito; import warehouse.quality.Locked; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map;
package warehouse.products; /** * Created by michal on 13.07.2016. */ public class EventsAssert implements ProductStock.EventsContract { private final ProductStock.EventsContract delegate; private final List<Object> events = new LinkedList<>(); private final Map<Class<? extends Object>, Object> last = new HashMap<>(); public EventsAssert(ProductStock.EventsContract delegate) { this.delegate = delegate; } public EventsAssert() { delegate = Mockito.mock(ProductStock.EventsContract.class); } @Override public void emit(Registered event) { delegate.emit(event); addEvent(event); } @Override public void emit(Stored event) { delegate.emit(event); addEvent(event); } @Override public void emit(Picked event) { delegate.emit(event); addEvent(event); } @Override
// Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // Path: warehouse-model/src/test/java/warehouse/products/EventsAssert.java import org.assertj.core.api.AbstractObjectAssert; import org.assertj.core.api.Assertions; import org.mockito.Mockito; import warehouse.quality.Locked; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; package warehouse.products; /** * Created by michal on 13.07.2016. */ public class EventsAssert implements ProductStock.EventsContract { private final ProductStock.EventsContract delegate; private final List<Object> events = new LinkedList<>(); private final Map<Class<? extends Object>, Object> last = new HashMap<>(); public EventsAssert(ProductStock.EventsContract delegate) { this.delegate = delegate; } public EventsAssert() { delegate = Mockito.mock(ProductStock.EventsContract.class); } @Override public void emit(Registered event) { delegate.emit(event); addEvent(event); } @Override public void emit(Stored event) { delegate.emit(event); addEvent(event); } @Override public void emit(Picked event) { delegate.emit(event); addEvent(event); } @Override
public void emit(Locked event) {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/warehouse/products/ProductStockAgent.java
// Path: warehouse-infrastructure/src/main/java/tools/AgentQueue.java // public class AgentQueue { // // public interface Command { // void execute() throws Exception; // } // // public interface CommandWithResult<T> extends Query<T> { // T execute() throws Exception; // } // // public interface Query<T> { // T execute() throws Exception; // } // // private final Queue<Runnable> tasks = new ConcurrentLinkedDeque<>(); // private final ReentrantLock lock = new ReentrantLock(); // // public CompletionStage<?> command(Command command) { // CompletableFuture<?> future = new CompletableFuture<>(); // tasks.offer(new CommandTask(future, command)); // execute(); // return future; // } // // public <T> CompletionStage<T> command(CommandWithResult<T> command) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, command)); // execute(); // return future; // } // // public <T> CompletionStage<T> query(Query<T> query) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, query)); // execute(); // return future; // } // // public <T> T querySync(Query<T> query) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, query)); // execute(); // try { // return future.get(); // } catch (InterruptedException e) { // throw new RuntimeException(e.getCause()); // } catch (ExecutionException e) { // throw e.getCause() instanceof RuntimeException // ? ((RuntimeException) e.getCause()) // : new RuntimeException(e.getCause()); // } // } // // private void execute() { // if (lock.tryLock()) { // try { // while (!tasks.isEmpty()) { // Runnable task = tasks.poll(); // task.run(); // } // } finally { // lock.unlock(); // } // if (!tasks.isEmpty()) { // execute(); // } // } // } // // private static class CommandTask implements Runnable { // final CompletableFuture<?> future; // final Command command; // // private CommandTask(CompletableFuture<?> future, Command command) { // this.future = future; // this.command = command; // } // // @Override // public void run() { // try { // command.execute(); // future.complete(null); // } catch (Throwable t) { // future.completeExceptionally(t); // } // } // } // // private static class QueryTask<T> implements Runnable { // final CompletableFuture<T> future; // final Query<T> query; // // private QueryTask(CompletableFuture<T> future, Query<T> query) { // this.future = future; // this.query = query; // } // // @Override // public void run() { // try { // future.complete(query.execute()); // } catch (Throwable t) { // future.completeExceptionally(t); // } // } // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import lombok.AllArgsConstructor; import tools.AgentQueue; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.util.List; import java.util.concurrent.CompletionStage;
package warehouse.products; /** * Created by michal on 10.10.2017. */ @AllArgsConstructor public class ProductStockAgent { private final String refNo; private final ProductStock object; private final ProductStockEventSourcingRepository.ProductStockEventsHandler events;
// Path: warehouse-infrastructure/src/main/java/tools/AgentQueue.java // public class AgentQueue { // // public interface Command { // void execute() throws Exception; // } // // public interface CommandWithResult<T> extends Query<T> { // T execute() throws Exception; // } // // public interface Query<T> { // T execute() throws Exception; // } // // private final Queue<Runnable> tasks = new ConcurrentLinkedDeque<>(); // private final ReentrantLock lock = new ReentrantLock(); // // public CompletionStage<?> command(Command command) { // CompletableFuture<?> future = new CompletableFuture<>(); // tasks.offer(new CommandTask(future, command)); // execute(); // return future; // } // // public <T> CompletionStage<T> command(CommandWithResult<T> command) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, command)); // execute(); // return future; // } // // public <T> CompletionStage<T> query(Query<T> query) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, query)); // execute(); // return future; // } // // public <T> T querySync(Query<T> query) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, query)); // execute(); // try { // return future.get(); // } catch (InterruptedException e) { // throw new RuntimeException(e.getCause()); // } catch (ExecutionException e) { // throw e.getCause() instanceof RuntimeException // ? ((RuntimeException) e.getCause()) // : new RuntimeException(e.getCause()); // } // } // // private void execute() { // if (lock.tryLock()) { // try { // while (!tasks.isEmpty()) { // Runnable task = tasks.poll(); // task.run(); // } // } finally { // lock.unlock(); // } // if (!tasks.isEmpty()) { // execute(); // } // } // } // // private static class CommandTask implements Runnable { // final CompletableFuture<?> future; // final Command command; // // private CommandTask(CompletableFuture<?> future, Command command) { // this.future = future; // this.command = command; // } // // @Override // public void run() { // try { // command.execute(); // future.complete(null); // } catch (Throwable t) { // future.completeExceptionally(t); // } // } // } // // private static class QueryTask<T> implements Runnable { // final CompletableFuture<T> future; // final Query<T> query; // // private QueryTask(CompletableFuture<T> future, Query<T> query) { // this.future = future; // this.query = query; // } // // @Override // public void run() { // try { // future.complete(query.execute()); // } catch (Throwable t) { // future.completeExceptionally(t); // } // } // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockAgent.java import lombok.AllArgsConstructor; import tools.AgentQueue; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.util.List; import java.util.concurrent.CompletionStage; package warehouse.products; /** * Created by michal on 10.10.2017. */ @AllArgsConstructor public class ProductStockAgent { private final String refNo; private final ProductStock object; private final ProductStockEventSourcingRepository.ProductStockEventsHandler events;
private final AgentQueue queue;
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/warehouse/products/ProductStockAgent.java
// Path: warehouse-infrastructure/src/main/java/tools/AgentQueue.java // public class AgentQueue { // // public interface Command { // void execute() throws Exception; // } // // public interface CommandWithResult<T> extends Query<T> { // T execute() throws Exception; // } // // public interface Query<T> { // T execute() throws Exception; // } // // private final Queue<Runnable> tasks = new ConcurrentLinkedDeque<>(); // private final ReentrantLock lock = new ReentrantLock(); // // public CompletionStage<?> command(Command command) { // CompletableFuture<?> future = new CompletableFuture<>(); // tasks.offer(new CommandTask(future, command)); // execute(); // return future; // } // // public <T> CompletionStage<T> command(CommandWithResult<T> command) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, command)); // execute(); // return future; // } // // public <T> CompletionStage<T> query(Query<T> query) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, query)); // execute(); // return future; // } // // public <T> T querySync(Query<T> query) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, query)); // execute(); // try { // return future.get(); // } catch (InterruptedException e) { // throw new RuntimeException(e.getCause()); // } catch (ExecutionException e) { // throw e.getCause() instanceof RuntimeException // ? ((RuntimeException) e.getCause()) // : new RuntimeException(e.getCause()); // } // } // // private void execute() { // if (lock.tryLock()) { // try { // while (!tasks.isEmpty()) { // Runnable task = tasks.poll(); // task.run(); // } // } finally { // lock.unlock(); // } // if (!tasks.isEmpty()) { // execute(); // } // } // } // // private static class CommandTask implements Runnable { // final CompletableFuture<?> future; // final Command command; // // private CommandTask(CompletableFuture<?> future, Command command) { // this.future = future; // this.command = command; // } // // @Override // public void run() { // try { // command.execute(); // future.complete(null); // } catch (Throwable t) { // future.completeExceptionally(t); // } // } // } // // private static class QueryTask<T> implements Runnable { // final CompletableFuture<T> future; // final Query<T> query; // // private QueryTask(CompletableFuture<T> future, Query<T> query) { // this.future = future; // this.query = query; // } // // @Override // public void run() { // try { // future.complete(query.execute()); // } catch (Throwable t) { // future.completeExceptionally(t); // } // } // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import lombok.AllArgsConstructor; import tools.AgentQueue; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.util.List; import java.util.concurrent.CompletionStage;
package warehouse.products; /** * Created by michal on 10.10.2017. */ @AllArgsConstructor public class ProductStockAgent { private final String refNo; private final ProductStock object; private final ProductStockEventSourcingRepository.ProductStockEventsHandler events; private final AgentQueue queue; public String getRefNo() { return refNo; } public CompletionStage<List<Object>> registerNew(RegisterNew registerNew) { return queue.command(() -> object.registerNew(registerNew)) .thenApply(o -> events.getLast()); } public CompletionStage<List<Object>> pick(Pick pick) { return queue.command(() -> object.pick(pick)) .thenApply(o -> events.getLast()); } public CompletionStage<List<Object>> store(Store store) { return queue.command(() -> object.store(store)) .thenApply(o -> events.getLast()); } public CompletionStage<List<Object>> delivered(Delivered event) { return queue.command(() -> object.delivered(event)) .thenApply(o -> events.getLast()); }
// Path: warehouse-infrastructure/src/main/java/tools/AgentQueue.java // public class AgentQueue { // // public interface Command { // void execute() throws Exception; // } // // public interface CommandWithResult<T> extends Query<T> { // T execute() throws Exception; // } // // public interface Query<T> { // T execute() throws Exception; // } // // private final Queue<Runnable> tasks = new ConcurrentLinkedDeque<>(); // private final ReentrantLock lock = new ReentrantLock(); // // public CompletionStage<?> command(Command command) { // CompletableFuture<?> future = new CompletableFuture<>(); // tasks.offer(new CommandTask(future, command)); // execute(); // return future; // } // // public <T> CompletionStage<T> command(CommandWithResult<T> command) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, command)); // execute(); // return future; // } // // public <T> CompletionStage<T> query(Query<T> query) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, query)); // execute(); // return future; // } // // public <T> T querySync(Query<T> query) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, query)); // execute(); // try { // return future.get(); // } catch (InterruptedException e) { // throw new RuntimeException(e.getCause()); // } catch (ExecutionException e) { // throw e.getCause() instanceof RuntimeException // ? ((RuntimeException) e.getCause()) // : new RuntimeException(e.getCause()); // } // } // // private void execute() { // if (lock.tryLock()) { // try { // while (!tasks.isEmpty()) { // Runnable task = tasks.poll(); // task.run(); // } // } finally { // lock.unlock(); // } // if (!tasks.isEmpty()) { // execute(); // } // } // } // // private static class CommandTask implements Runnable { // final CompletableFuture<?> future; // final Command command; // // private CommandTask(CompletableFuture<?> future, Command command) { // this.future = future; // this.command = command; // } // // @Override // public void run() { // try { // command.execute(); // future.complete(null); // } catch (Throwable t) { // future.completeExceptionally(t); // } // } // } // // private static class QueryTask<T> implements Runnable { // final CompletableFuture<T> future; // final Query<T> query; // // private QueryTask(CompletableFuture<T> future, Query<T> query) { // this.future = future; // this.query = query; // } // // @Override // public void run() { // try { // future.complete(query.execute()); // } catch (Throwable t) { // future.completeExceptionally(t); // } // } // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockAgent.java import lombok.AllArgsConstructor; import tools.AgentQueue; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.util.List; import java.util.concurrent.CompletionStage; package warehouse.products; /** * Created by michal on 10.10.2017. */ @AllArgsConstructor public class ProductStockAgent { private final String refNo; private final ProductStock object; private final ProductStockEventSourcingRepository.ProductStockEventsHandler events; private final AgentQueue queue; public String getRefNo() { return refNo; } public CompletionStage<List<Object>> registerNew(RegisterNew registerNew) { return queue.command(() -> object.registerNew(registerNew)) .thenApply(o -> events.getLast()); } public CompletionStage<List<Object>> pick(Pick pick) { return queue.command(() -> object.pick(pick)) .thenApply(o -> events.getLast()); } public CompletionStage<List<Object>> store(Store store) { return queue.command(() -> object.store(store)) .thenApply(o -> events.getLast()); } public CompletionStage<List<Object>> delivered(Delivered event) { return queue.command(() -> object.delivered(event)) .thenApply(o -> events.getLast()); }
public CompletionStage<Location> getLocation(PaletteLabel paletteLabel) {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/warehouse/products/ProductStockAgent.java
// Path: warehouse-infrastructure/src/main/java/tools/AgentQueue.java // public class AgentQueue { // // public interface Command { // void execute() throws Exception; // } // // public interface CommandWithResult<T> extends Query<T> { // T execute() throws Exception; // } // // public interface Query<T> { // T execute() throws Exception; // } // // private final Queue<Runnable> tasks = new ConcurrentLinkedDeque<>(); // private final ReentrantLock lock = new ReentrantLock(); // // public CompletionStage<?> command(Command command) { // CompletableFuture<?> future = new CompletableFuture<>(); // tasks.offer(new CommandTask(future, command)); // execute(); // return future; // } // // public <T> CompletionStage<T> command(CommandWithResult<T> command) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, command)); // execute(); // return future; // } // // public <T> CompletionStage<T> query(Query<T> query) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, query)); // execute(); // return future; // } // // public <T> T querySync(Query<T> query) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, query)); // execute(); // try { // return future.get(); // } catch (InterruptedException e) { // throw new RuntimeException(e.getCause()); // } catch (ExecutionException e) { // throw e.getCause() instanceof RuntimeException // ? ((RuntimeException) e.getCause()) // : new RuntimeException(e.getCause()); // } // } // // private void execute() { // if (lock.tryLock()) { // try { // while (!tasks.isEmpty()) { // Runnable task = tasks.poll(); // task.run(); // } // } finally { // lock.unlock(); // } // if (!tasks.isEmpty()) { // execute(); // } // } // } // // private static class CommandTask implements Runnable { // final CompletableFuture<?> future; // final Command command; // // private CommandTask(CompletableFuture<?> future, Command command) { // this.future = future; // this.command = command; // } // // @Override // public void run() { // try { // command.execute(); // future.complete(null); // } catch (Throwable t) { // future.completeExceptionally(t); // } // } // } // // private static class QueryTask<T> implements Runnable { // final CompletableFuture<T> future; // final Query<T> query; // // private QueryTask(CompletableFuture<T> future, Query<T> query) { // this.future = future; // this.query = query; // } // // @Override // public void run() { // try { // future.complete(query.execute()); // } catch (Throwable t) { // future.completeExceptionally(t); // } // } // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import lombok.AllArgsConstructor; import tools.AgentQueue; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.util.List; import java.util.concurrent.CompletionStage;
package warehouse.products; /** * Created by michal on 10.10.2017. */ @AllArgsConstructor public class ProductStockAgent { private final String refNo; private final ProductStock object; private final ProductStockEventSourcingRepository.ProductStockEventsHandler events; private final AgentQueue queue; public String getRefNo() { return refNo; } public CompletionStage<List<Object>> registerNew(RegisterNew registerNew) { return queue.command(() -> object.registerNew(registerNew)) .thenApply(o -> events.getLast()); } public CompletionStage<List<Object>> pick(Pick pick) { return queue.command(() -> object.pick(pick)) .thenApply(o -> events.getLast()); } public CompletionStage<List<Object>> store(Store store) { return queue.command(() -> object.store(store)) .thenApply(o -> events.getLast()); } public CompletionStage<List<Object>> delivered(Delivered event) { return queue.command(() -> object.delivered(event)) .thenApply(o -> events.getLast()); }
// Path: warehouse-infrastructure/src/main/java/tools/AgentQueue.java // public class AgentQueue { // // public interface Command { // void execute() throws Exception; // } // // public interface CommandWithResult<T> extends Query<T> { // T execute() throws Exception; // } // // public interface Query<T> { // T execute() throws Exception; // } // // private final Queue<Runnable> tasks = new ConcurrentLinkedDeque<>(); // private final ReentrantLock lock = new ReentrantLock(); // // public CompletionStage<?> command(Command command) { // CompletableFuture<?> future = new CompletableFuture<>(); // tasks.offer(new CommandTask(future, command)); // execute(); // return future; // } // // public <T> CompletionStage<T> command(CommandWithResult<T> command) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, command)); // execute(); // return future; // } // // public <T> CompletionStage<T> query(Query<T> query) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, query)); // execute(); // return future; // } // // public <T> T querySync(Query<T> query) { // CompletableFuture<T> future = new CompletableFuture<>(); // tasks.offer(new QueryTask<>(future, query)); // execute(); // try { // return future.get(); // } catch (InterruptedException e) { // throw new RuntimeException(e.getCause()); // } catch (ExecutionException e) { // throw e.getCause() instanceof RuntimeException // ? ((RuntimeException) e.getCause()) // : new RuntimeException(e.getCause()); // } // } // // private void execute() { // if (lock.tryLock()) { // try { // while (!tasks.isEmpty()) { // Runnable task = tasks.poll(); // task.run(); // } // } finally { // lock.unlock(); // } // if (!tasks.isEmpty()) { // execute(); // } // } // } // // private static class CommandTask implements Runnable { // final CompletableFuture<?> future; // final Command command; // // private CommandTask(CompletableFuture<?> future, Command command) { // this.future = future; // this.command = command; // } // // @Override // public void run() { // try { // command.execute(); // future.complete(null); // } catch (Throwable t) { // future.completeExceptionally(t); // } // } // } // // private static class QueryTask<T> implements Runnable { // final CompletableFuture<T> future; // final Query<T> query; // // private QueryTask(CompletableFuture<T> future, Query<T> query) { // this.future = future; // this.query = query; // } // // @Override // public void run() { // try { // future.complete(query.execute()); // } catch (Throwable t) { // future.completeExceptionally(t); // } // } // } // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockAgent.java import lombok.AllArgsConstructor; import tools.AgentQueue; import warehouse.PaletteLabel; import warehouse.locations.Location; import java.util.List; import java.util.concurrent.CompletionStage; package warehouse.products; /** * Created by michal on 10.10.2017. */ @AllArgsConstructor public class ProductStockAgent { private final String refNo; private final ProductStock object; private final ProductStockEventSourcingRepository.ProductStockEventsHandler events; private final AgentQueue queue; public String getRefNo() { return refNo; } public CompletionStage<List<Object>> registerNew(RegisterNew registerNew) { return queue.command(() -> object.registerNew(registerNew)) .thenApply(o -> events.getLast()); } public CompletionStage<List<Object>> pick(Pick pick) { return queue.command(() -> object.pick(pick)) .thenApply(o -> events.getLast()); } public CompletionStage<List<Object>> store(Store store) { return queue.command(() -> object.store(store)) .thenApply(o -> events.getLast()); } public CompletionStage<List<Object>> delivered(Delivered event) { return queue.command(() -> object.delivered(event)) .thenApply(o -> events.getLast()); }
public CompletionStage<Location> getLocation(PaletteLabel paletteLabel) {
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/Stored.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location;
package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Stored {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/main/java/warehouse/products/Stored.java import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location; package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Stored {
private final PaletteLabel paletteLabel;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/Stored.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location;
package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Stored { private final PaletteLabel paletteLabel;
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/main/java/warehouse/products/Stored.java import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location; package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Stored { private final PaletteLabel paletteLabel;
private final Location location;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/Store.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location;
package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Store {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/main/java/warehouse/products/Store.java import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location; package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Store {
private final PaletteLabel paletteLabel;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/Store.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // }
import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location;
package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Store { private final PaletteLabel paletteLabel;
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // Path: warehouse-model/src/main/java/warehouse/products/Store.java import lombok.Value; import warehouse.PaletteLabel; import warehouse.locations.Location; package warehouse.products; /** * Created by michal on 13.07.2016. */ @Value public class Store { private final PaletteLabel paletteLabel;
private final Location location;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/Delivered.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // }
import lombok.Value; import warehouse.PaletteLabel;
package warehouse.products; /** * Created by michal on 10.08.2016. */ @Value public class Delivered {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // Path: warehouse-model/src/main/java/warehouse/products/Delivered.java import lombok.Value; import warehouse.PaletteLabel; package warehouse.products; /** * Created by michal on 10.08.2016. */ @Value public class Delivered {
private final PaletteLabel paletteLabel;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/products/CartValidatorTest.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // }
import org.assertj.core.api.Assertions; import org.junit.Test; import warehouse.BoxLabel; import warehouse.PaletteLabel; import java.util.Arrays; import java.util.stream.Collectors; import java.util.stream.Stream;
package warehouse.products; /** * Created by michal on 23.10.2017. */ public class CartValidatorTest { private final String cartRefNo = "900900";
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // Path: warehouse-model/src/test/java/warehouse/products/CartValidatorTest.java import org.assertj.core.api.Assertions; import org.junit.Test; import warehouse.BoxLabel; import warehouse.PaletteLabel; import java.util.Arrays; import java.util.stream.Collectors; import java.util.stream.Stream; package warehouse.products; /** * Created by michal on 23.10.2017. */ public class CartValidatorTest { private final String cartRefNo = "900900";
private final PaletteLabel cartLabel = new PaletteLabel("C-900900-0001", cartRefNo);
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/test/java/warehouse/products/CartValidatorTest.java
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // }
import org.assertj.core.api.Assertions; import org.junit.Test; import warehouse.BoxLabel; import warehouse.PaletteLabel; import java.util.Arrays; import java.util.stream.Collectors; import java.util.stream.Stream;
@Test public void someProductMissingSomeProductNotExpected() throws Exception { requiredProductsInCart("900901", "900902", "900903", "900904"); RegisterNew command = givenCartRegistrationCommand("9009XXXX", "900902", "900903", "900904"); ValidationResult result = validator.validate(command); Assertions.assertThat(result.getViolations()) .contains( "not expected refNo 9009XXXX", "refNo 900901 expected in pocket 1, but not found"); } @Test public void someProductExpectedInOtherPocket() throws Exception { requiredProductsInCart("900901", "900902", "900903", "900904"); RegisterNew command = givenCartRegistrationCommand("900902", "900901", "900903", "900904"); ValidationResult result = validator.validate(command); Assertions.assertThat(result.getViolations()) .contains( "refNo 900901 expected in pocket 1, but found in 2", "refNo 900902 expected in pocket 2, but found in 1"); } private RegisterNew givenCartRegistrationCommand(String... labels) { return new RegisterNew(cartLabel, Stream.of(labels)
// Path: warehouse-model/src/main/java/warehouse/BoxLabel.java // @Value // public class BoxLabel { // private final String refNo; // private final int quantity; // private final String boxType; // } // // Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // Path: warehouse-model/src/test/java/warehouse/products/CartValidatorTest.java import org.assertj.core.api.Assertions; import org.junit.Test; import warehouse.BoxLabel; import warehouse.PaletteLabel; import java.util.Arrays; import java.util.stream.Collectors; import java.util.stream.Stream; @Test public void someProductMissingSomeProductNotExpected() throws Exception { requiredProductsInCart("900901", "900902", "900903", "900904"); RegisterNew command = givenCartRegistrationCommand("9009XXXX", "900902", "900903", "900904"); ValidationResult result = validator.validate(command); Assertions.assertThat(result.getViolations()) .contains( "not expected refNo 9009XXXX", "refNo 900901 expected in pocket 1, but not found"); } @Test public void someProductExpectedInOtherPocket() throws Exception { requiredProductsInCart("900901", "900902", "900903", "900904"); RegisterNew command = givenCartRegistrationCommand("900902", "900901", "900903", "900904"); ValidationResult result = validator.validate(command); Assertions.assertThat(result.getViolations()) .contains( "refNo 900901 expected in pocket 1, but found in 2", "refNo 900902 expected in pocket 2, but found in 1"); } private RegisterNew givenCartRegistrationCommand(String... labels) { return new RegisterNew(cartLabel, Stream.of(labels)
.map(l -> new BoxLabel(l, 1, "POCKET"))
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/quality/Unlocked.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // }
import lombok.Value; import warehouse.PaletteLabel;
package warehouse.quality; /** * Created by michal on 14.08.2016. */ @Value public class Unlocked {
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java import lombok.Value; import warehouse.PaletteLabel; package warehouse.quality; /** * Created by michal on 14.08.2016. */ @Value public class Unlocked {
private final PaletteLabel paletteLabel;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/ProductStock.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // }
import lombok.AllArgsConstructor; import lombok.Data; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import java.time.Clock; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map;
package warehouse.products; /** * Created by michal on 08.06.2016. */ @AllArgsConstructor public class ProductStock { private String refNo;
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // Path: warehouse-model/src/main/java/warehouse/products/ProductStock.java import lombok.AllArgsConstructor; import lombok.Data; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import java.time.Clock; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map; package warehouse.products; /** * Created by michal on 08.06.2016. */ @AllArgsConstructor public class ProductStock { private String refNo;
private PreferredLocationPicker locationPicker;
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/ProductStock.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // }
import lombok.AllArgsConstructor; import lombok.Data; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import java.time.Clock; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map;
package warehouse.products; /** * Created by michal on 08.06.2016. */ @AllArgsConstructor public class ProductStock { private String refNo; private PreferredLocationPicker locationPicker; private StorageUnitValidator validator; private EventsContract events; private Clock clock;
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // Path: warehouse-model/src/main/java/warehouse/products/ProductStock.java import lombok.AllArgsConstructor; import lombok.Data; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import java.time.Clock; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map; package warehouse.products; /** * Created by michal on 08.06.2016. */ @AllArgsConstructor public class ProductStock { private String refNo; private PreferredLocationPicker locationPicker; private StorageUnitValidator validator; private EventsContract events; private Clock clock;
private final Map<PaletteLabel, PaletteInformation> stock = new HashMap<>();
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/ProductStock.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // }
import lombok.AllArgsConstructor; import lombok.Data; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import java.time.Clock; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map;
package warehouse.products; /** * Created by michal on 08.06.2016. */ @AllArgsConstructor public class ProductStock { private String refNo; private PreferredLocationPicker locationPicker; private StorageUnitValidator validator; private EventsContract events; private Clock clock; private final Map<PaletteLabel, PaletteInformation> stock = new HashMap<>(); public interface EventsContract { void emit(Registered event); void emit(Stored event); void emit(Picked event);
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // Path: warehouse-model/src/main/java/warehouse/products/ProductStock.java import lombok.AllArgsConstructor; import lombok.Data; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import java.time.Clock; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map; package warehouse.products; /** * Created by michal on 08.06.2016. */ @AllArgsConstructor public class ProductStock { private String refNo; private PreferredLocationPicker locationPicker; private StorageUnitValidator validator; private EventsContract events; private Clock clock; private final Map<PaletteLabel, PaletteInformation> stock = new HashMap<>(); public interface EventsContract { void emit(Registered event); void emit(Stored event); void emit(Picked event);
void emit(Locked lock);
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/ProductStock.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // }
import lombok.AllArgsConstructor; import lombok.Data; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import java.time.Clock; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map;
package warehouse.products; /** * Created by michal on 08.06.2016. */ @AllArgsConstructor public class ProductStock { private String refNo; private PreferredLocationPicker locationPicker; private StorageUnitValidator validator; private EventsContract events; private Clock clock; private final Map<PaletteLabel, PaletteInformation> stock = new HashMap<>(); public interface EventsContract { void emit(Registered event); void emit(Stored event); void emit(Picked event); void emit(Locked lock); } public void registerNew(RegisterNew registerNew) { assert refNo.equals(registerNew.getPaletteLabel().getRefNo()); if (stock.containsKey(registerNew.getPaletteLabel())) { return; } ValidationResult validation = validator.validate(registerNew);
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // Path: warehouse-model/src/main/java/warehouse/products/ProductStock.java import lombok.AllArgsConstructor; import lombok.Data; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import java.time.Clock; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map; package warehouse.products; /** * Created by michal on 08.06.2016. */ @AllArgsConstructor public class ProductStock { private String refNo; private PreferredLocationPicker locationPicker; private StorageUnitValidator validator; private EventsContract events; private Clock clock; private final Map<PaletteLabel, PaletteInformation> stock = new HashMap<>(); public interface EventsContract { void emit(Registered event); void emit(Stored event); void emit(Picked event); void emit(Locked lock); } public void registerNew(RegisterNew registerNew) { assert refNo.equals(registerNew.getPaletteLabel().getRefNo()); if (stock.containsKey(registerNew.getPaletteLabel())) { return; } ValidationResult validation = validator.validate(registerNew);
Location suggestedLocation = validation.isValid()
michal-michaluk/ddd-wro-warehouse
warehouse-model/src/main/java/warehouse/products/ProductStock.java
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // }
import lombok.AllArgsConstructor; import lombok.Data; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import java.time.Clock; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map;
events.emit(event); if (!validation.isValid()) { Locked lock = new Locked(registerNew.getPaletteLabel()); events.emit(lock); } } public void pick(Pick pick) { assert refNo.equals(pick.getPaletteLabel().getRefNo()); Location fromLocation = stock.get(pick.getPaletteLabel()).currentLocation; Picked event = new Picked(pick.getPaletteLabel(), pick.getUser(), fromLocation, Location.onTheMove(pick.getUser())); apply(event); events.emit(event); } public void store(Store store) { assert refNo.equals(store.getPaletteLabel().getRefNo()); Stored event = new Stored( store.getPaletteLabel(), store.getLocation()); apply(event); events.emit(event); } public void delivered(Delivered event) { stock.remove(event.getPaletteLabel()); }
// Path: warehouse-model/src/main/java/warehouse/PaletteLabel.java // @Value // public class PaletteLabel { // private final String id; // private final String refNo; // // @Override // public String toString() { // return id; // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/Location.java // @Value // public class Location { // private final String location; // // public static Location production() { // return new Location("production"); // } // // public static Location quarantine() { // return new Location("quarantine"); // } // // public static Location onTheMove(String user) { // return new Location("picked by " + user); // } // // public static Location unknown() { // return new Location("<unknown>"); // } // } // // Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // Path: warehouse-model/src/main/java/warehouse/products/ProductStock.java import lombok.AllArgsConstructor; import lombok.Data; import warehouse.PaletteLabel; import warehouse.locations.Location; import warehouse.locations.PreferredLocationPicker; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import java.time.Clock; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map; events.emit(event); if (!validation.isValid()) { Locked lock = new Locked(registerNew.getPaletteLabel()); events.emit(lock); } } public void pick(Pick pick) { assert refNo.equals(pick.getPaletteLabel().getRefNo()); Location fromLocation = stock.get(pick.getPaletteLabel()).currentLocation; Picked event = new Picked(pick.getPaletteLabel(), pick.getUser(), fromLocation, Location.onTheMove(pick.getUser())); apply(event); events.emit(event); } public void store(Store store) { assert refNo.equals(store.getPaletteLabel().getRefNo()); Stored event = new Stored( store.getPaletteLabel(), store.getLocation()); apply(event); events.emit(event); } public void delivered(Delivered event) { stock.remove(event.getPaletteLabel()); }
public void destroyed(Destroyed event) {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/warehouse/OpsSupport.java
// Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockAgent.java // @AllArgsConstructor // public class ProductStockAgent { // // private final String refNo; // private final ProductStock object; // private final ProductStockEventSourcingRepository.ProductStockEventsHandler events; // private final AgentQueue queue; // // public String getRefNo() { // return refNo; // } // // public CompletionStage<List<Object>> registerNew(RegisterNew registerNew) { // return queue.command(() -> object.registerNew(registerNew)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<List<Object>> pick(Pick pick) { // return queue.command(() -> object.pick(pick)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<List<Object>> store(Store store) { // return queue.command(() -> object.store(store)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<List<Object>> delivered(Delivered event) { // return queue.command(() -> object.delivered(event)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<Location> getLocation(PaletteLabel paletteLabel) { // return queue.query(() -> object.getLocation(paletteLabel)); // } // // public Location getLocationSync(PaletteLabel paletteLabel) { // return queue.querySync(() -> object.getLocation(paletteLabel)); // } // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import spark.Request; import warehouse.locations.PreferredLocationPicker; import warehouse.products.ProductStockAgent; import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors;
package warehouse; /** * Created by michal on 20.10.2017. */ public class OpsSupport { private static final Logger PRODUCT_STOCK = LoggerFactory.getLogger("warehouse.OpsSupport.PRODUCT_STOCK"); private static final Logger FIFO_VIEW = LoggerFactory.getLogger("warehouse.OpsSupport.FIFO_VIEW"); private static final Logger QUALITY_REPORT = LoggerFactory.getLogger("warehouse.OpsSupport.QUALITY_REPORT"); private static final Logger MASTER_DATA = LoggerFactory.getLogger("warehouse.OpsSupport.MASTER_DATA");
// Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockAgent.java // @AllArgsConstructor // public class ProductStockAgent { // // private final String refNo; // private final ProductStock object; // private final ProductStockEventSourcingRepository.ProductStockEventsHandler events; // private final AgentQueue queue; // // public String getRefNo() { // return refNo; // } // // public CompletionStage<List<Object>> registerNew(RegisterNew registerNew) { // return queue.command(() -> object.registerNew(registerNew)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<List<Object>> pick(Pick pick) { // return queue.command(() -> object.pick(pick)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<List<Object>> store(Store store) { // return queue.command(() -> object.store(store)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<List<Object>> delivered(Delivered event) { // return queue.command(() -> object.delivered(event)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<Location> getLocation(PaletteLabel paletteLabel) { // return queue.query(() -> object.getLocation(paletteLabel)); // } // // public Location getLocationSync(PaletteLabel paletteLabel) { // return queue.querySync(() -> object.getLocation(paletteLabel)); // } // } // Path: warehouse-infrastructure/src/main/java/warehouse/OpsSupport.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import spark.Request; import warehouse.locations.PreferredLocationPicker; import warehouse.products.ProductStockAgent; import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; package warehouse; /** * Created by michal on 20.10.2017. */ public class OpsSupport { private static final Logger PRODUCT_STOCK = LoggerFactory.getLogger("warehouse.OpsSupport.PRODUCT_STOCK"); private static final Logger FIFO_VIEW = LoggerFactory.getLogger("warehouse.OpsSupport.FIFO_VIEW"); private static final Logger QUALITY_REPORT = LoggerFactory.getLogger("warehouse.OpsSupport.QUALITY_REPORT"); private static final Logger MASTER_DATA = LoggerFactory.getLogger("warehouse.OpsSupport.MASTER_DATA");
public void initialisingStockForNewProduct(String refNo, PreferredLocationPicker locationPicker) {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/warehouse/OpsSupport.java
// Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockAgent.java // @AllArgsConstructor // public class ProductStockAgent { // // private final String refNo; // private final ProductStock object; // private final ProductStockEventSourcingRepository.ProductStockEventsHandler events; // private final AgentQueue queue; // // public String getRefNo() { // return refNo; // } // // public CompletionStage<List<Object>> registerNew(RegisterNew registerNew) { // return queue.command(() -> object.registerNew(registerNew)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<List<Object>> pick(Pick pick) { // return queue.command(() -> object.pick(pick)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<List<Object>> store(Store store) { // return queue.command(() -> object.store(store)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<List<Object>> delivered(Delivered event) { // return queue.command(() -> object.delivered(event)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<Location> getLocation(PaletteLabel paletteLabel) { // return queue.query(() -> object.getLocation(paletteLabel)); // } // // public Location getLocationSync(PaletteLabel paletteLabel) { // return queue.querySync(() -> object.getLocation(paletteLabel)); // } // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import spark.Request; import warehouse.locations.PreferredLocationPicker; import warehouse.products.ProductStockAgent; import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors;
package warehouse; /** * Created by michal on 20.10.2017. */ public class OpsSupport { private static final Logger PRODUCT_STOCK = LoggerFactory.getLogger("warehouse.OpsSupport.PRODUCT_STOCK"); private static final Logger FIFO_VIEW = LoggerFactory.getLogger("warehouse.OpsSupport.FIFO_VIEW"); private static final Logger QUALITY_REPORT = LoggerFactory.getLogger("warehouse.OpsSupport.QUALITY_REPORT"); private static final Logger MASTER_DATA = LoggerFactory.getLogger("warehouse.OpsSupport.MASTER_DATA"); public void initialisingStockForNewProduct(String refNo, PreferredLocationPicker locationPicker) { PRODUCT_STOCK.info("{}: initialising stock for new refNo: {}, default setting: {}, {}", refNo, refNo, toSimpleName(locationPicker)); }
// Path: warehouse-model/src/main/java/warehouse/locations/PreferredLocationPicker.java // public interface PreferredLocationPicker { // Location suggestFor(String refNo); // } // // Path: warehouse-infrastructure/src/main/java/warehouse/products/ProductStockAgent.java // @AllArgsConstructor // public class ProductStockAgent { // // private final String refNo; // private final ProductStock object; // private final ProductStockEventSourcingRepository.ProductStockEventsHandler events; // private final AgentQueue queue; // // public String getRefNo() { // return refNo; // } // // public CompletionStage<List<Object>> registerNew(RegisterNew registerNew) { // return queue.command(() -> object.registerNew(registerNew)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<List<Object>> pick(Pick pick) { // return queue.command(() -> object.pick(pick)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<List<Object>> store(Store store) { // return queue.command(() -> object.store(store)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<List<Object>> delivered(Delivered event) { // return queue.command(() -> object.delivered(event)) // .thenApply(o -> events.getLast()); // } // // public CompletionStage<Location> getLocation(PaletteLabel paletteLabel) { // return queue.query(() -> object.getLocation(paletteLabel)); // } // // public Location getLocationSync(PaletteLabel paletteLabel) { // return queue.querySync(() -> object.getLocation(paletteLabel)); // } // } // Path: warehouse-infrastructure/src/main/java/warehouse/OpsSupport.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import spark.Request; import warehouse.locations.PreferredLocationPicker; import warehouse.products.ProductStockAgent; import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; package warehouse; /** * Created by michal on 20.10.2017. */ public class OpsSupport { private static final Logger PRODUCT_STOCK = LoggerFactory.getLogger("warehouse.OpsSupport.PRODUCT_STOCK"); private static final Logger FIFO_VIEW = LoggerFactory.getLogger("warehouse.OpsSupport.FIFO_VIEW"); private static final Logger QUALITY_REPORT = LoggerFactory.getLogger("warehouse.OpsSupport.QUALITY_REPORT"); private static final Logger MASTER_DATA = LoggerFactory.getLogger("warehouse.OpsSupport.MASTER_DATA"); public void initialisingStockForNewProduct(String refNo, PreferredLocationPicker locationPicker) { PRODUCT_STOCK.info("{}: initialising stock for new refNo: {}, default setting: {}, {}", refNo, refNo, toSimpleName(locationPicker)); }
public <T> T executedCommandOnProductStock(Request request, ProductStockAgent stock, Object command, Throwable throwable) {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/warehouse/EventMappings.java
// Path: warehouse-model/src/main/java/warehouse/picklist/FifoRepository.java // public interface FifoRepository { // Fifo get(); // // void handle(String refNo, Object event); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.AllArgsConstructor; import warehouse.picklist.FifoRepository; import warehouse.products.*; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.util.concurrent.CompletableFuture;
package warehouse; /** * Created by michal on 16.07.2016. */ public class EventMappings { private ProductStockAgentRepository stocks;
// Path: warehouse-model/src/main/java/warehouse/picklist/FifoRepository.java // public interface FifoRepository { // Fifo get(); // // void handle(String refNo, Object event); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java import lombok.AllArgsConstructor; import warehouse.picklist.FifoRepository; import warehouse.products.*; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.util.concurrent.CompletableFuture; package warehouse; /** * Created by michal on 16.07.2016. */ public class EventMappings { private ProductStockAgentRepository stocks;
private FifoRepository fifo;
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/warehouse/EventMappings.java
// Path: warehouse-model/src/main/java/warehouse/picklist/FifoRepository.java // public interface FifoRepository { // Fifo get(); // // void handle(String refNo, Object event); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.AllArgsConstructor; import warehouse.picklist.FifoRepository; import warehouse.products.*; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.util.concurrent.CompletableFuture;
package warehouse; /** * Created by michal on 16.07.2016. */ public class EventMappings { private ProductStockAgentRepository stocks; private FifoRepository fifo; private OpsSupport support; public ExternalEvents externalEvents() { return new ExternalEvents(); } public ProductStock.EventsContract productStocks() { return new ProductStocks(); } @AllArgsConstructor public class ExternalEvents {
// Path: warehouse-model/src/main/java/warehouse/picklist/FifoRepository.java // public interface FifoRepository { // Fifo get(); // // void handle(String refNo, Object event); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java import lombok.AllArgsConstructor; import warehouse.picklist.FifoRepository; import warehouse.products.*; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.util.concurrent.CompletableFuture; package warehouse; /** * Created by michal on 16.07.2016. */ public class EventMappings { private ProductStockAgentRepository stocks; private FifoRepository fifo; private OpsSupport support; public ExternalEvents externalEvents() { return new ExternalEvents(); } public ProductStock.EventsContract productStocks() { return new ProductStocks(); } @AllArgsConstructor public class ExternalEvents {
public void emit(Locked event) {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/warehouse/EventMappings.java
// Path: warehouse-model/src/main/java/warehouse/picklist/FifoRepository.java // public interface FifoRepository { // Fifo get(); // // void handle(String refNo, Object event); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.AllArgsConstructor; import warehouse.picklist.FifoRepository; import warehouse.products.*; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.util.concurrent.CompletableFuture;
package warehouse; /** * Created by michal on 16.07.2016. */ public class EventMappings { private ProductStockAgentRepository stocks; private FifoRepository fifo; private OpsSupport support; public ExternalEvents externalEvents() { return new ExternalEvents(); } public ProductStock.EventsContract productStocks() { return new ProductStocks(); } @AllArgsConstructor public class ExternalEvents { public void emit(Locked event) { fifo.handle(event.getPaletteLabel().getRefNo(), event); }
// Path: warehouse-model/src/main/java/warehouse/picklist/FifoRepository.java // public interface FifoRepository { // Fifo get(); // // void handle(String refNo, Object event); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java import lombok.AllArgsConstructor; import warehouse.picklist.FifoRepository; import warehouse.products.*; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.util.concurrent.CompletableFuture; package warehouse; /** * Created by michal on 16.07.2016. */ public class EventMappings { private ProductStockAgentRepository stocks; private FifoRepository fifo; private OpsSupport support; public ExternalEvents externalEvents() { return new ExternalEvents(); } public ProductStock.EventsContract productStocks() { return new ProductStocks(); } @AllArgsConstructor public class ExternalEvents { public void emit(Locked event) { fifo.handle(event.getPaletteLabel().getRefNo(), event); }
public void emit(Unlocked event) {
michal-michaluk/ddd-wro-warehouse
warehouse-infrastructure/src/main/java/warehouse/EventMappings.java
// Path: warehouse-model/src/main/java/warehouse/picklist/FifoRepository.java // public interface FifoRepository { // Fifo get(); // // void handle(String refNo, Object event); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // }
import lombok.AllArgsConstructor; import warehouse.picklist.FifoRepository; import warehouse.products.*; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.util.concurrent.CompletableFuture;
package warehouse; /** * Created by michal on 16.07.2016. */ public class EventMappings { private ProductStockAgentRepository stocks; private FifoRepository fifo; private OpsSupport support; public ExternalEvents externalEvents() { return new ExternalEvents(); } public ProductStock.EventsContract productStocks() { return new ProductStocks(); } @AllArgsConstructor public class ExternalEvents { public void emit(Locked event) { fifo.handle(event.getPaletteLabel().getRefNo(), event); } public void emit(Unlocked event) { fifo.handle(event.getPaletteLabel().getRefNo(), event); }
// Path: warehouse-model/src/main/java/warehouse/picklist/FifoRepository.java // public interface FifoRepository { // Fifo get(); // // void handle(String refNo, Object event); // } // // Path: warehouse-model/src/main/java/warehouse/quality/Destroyed.java // @Value // public class Destroyed { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Locked.java // @Value // public class Locked { // private final PaletteLabel paletteLabel; // } // // Path: warehouse-model/src/main/java/warehouse/quality/Unlocked.java // @Value // public class Unlocked { // private final PaletteLabel paletteLabel; // private final int recovered; // private final int scraped; // } // Path: warehouse-infrastructure/src/main/java/warehouse/EventMappings.java import lombok.AllArgsConstructor; import warehouse.picklist.FifoRepository; import warehouse.products.*; import warehouse.quality.Destroyed; import warehouse.quality.Locked; import warehouse.quality.Unlocked; import java.util.concurrent.CompletableFuture; package warehouse; /** * Created by michal on 16.07.2016. */ public class EventMappings { private ProductStockAgentRepository stocks; private FifoRepository fifo; private OpsSupport support; public ExternalEvents externalEvents() { return new ExternalEvents(); } public ProductStock.EventsContract productStocks() { return new ProductStocks(); } @AllArgsConstructor public class ExternalEvents { public void emit(Locked event) { fifo.handle(event.getPaletteLabel().getRefNo(), event); } public void emit(Unlocked event) { fifo.handle(event.getPaletteLabel().getRefNo(), event); }
public void emit(Destroyed event) {
HubSpot/NioSmtpClient
src/main/java/com/hubspot/smtp/client/NoopErrorResponseException.java
// Path: src/main/java/com/hubspot/smtp/utils/SmtpResponses.java // public final class SmtpResponses { // private static final Joiner SPACE_JOINER = Joiner.on(" ").skipNulls(); // // private SmtpResponses() { // throw new AssertionError("Cannot create static utility class"); // } // // public static String toString(SmtpResponse response) { // if (response.details().size() == 0) { // return Integer.toString(response.code()); // } else { // return response.code() + " " + SPACE_JOINER.join(response.details()); // } // } // // public static List<String> getLines(SmtpResponse response) { // if (response.details().size() == 0) { // return ImmutableList.of(Integer.toString(response.code())); // } // // String[] lines = new String[response.details().size()]; // // for (int i = 0; i < response.details().size(); i++) { // StringBuilder responseBuilder = new StringBuilder(); // // responseBuilder.append(response.code()); // // if (i == response.details().size() - 1) { // responseBuilder.append(" "); // } else { // responseBuilder.append("-"); // } // // responseBuilder.append(response.details().get(i)); // // lines[i] = responseBuilder.toString(); // } // // return ImmutableList.copyOf(lines); // } // // public static boolean isTransientError(SmtpResponse response) { // return response.code() >= 400 && response.code() < 500; // } // // public static boolean isPermanentError(SmtpResponse response) { // return response.code() >= 500; // } // // public static boolean isError(SmtpResponse response) { // return isTransientError(response) || isPermanentError(response); // } // }
import com.hubspot.smtp.utils.SmtpResponses; import io.netty.handler.codec.smtp.SmtpResponse;
package com.hubspot.smtp.client; /** * Unchecked exception thrown when an error was received in response to a NOOP command. * */ public class NoopErrorResponseException extends SmtpException { public NoopErrorResponseException(String connectionId, SmtpResponse response, String message) {
// Path: src/main/java/com/hubspot/smtp/utils/SmtpResponses.java // public final class SmtpResponses { // private static final Joiner SPACE_JOINER = Joiner.on(" ").skipNulls(); // // private SmtpResponses() { // throw new AssertionError("Cannot create static utility class"); // } // // public static String toString(SmtpResponse response) { // if (response.details().size() == 0) { // return Integer.toString(response.code()); // } else { // return response.code() + " " + SPACE_JOINER.join(response.details()); // } // } // // public static List<String> getLines(SmtpResponse response) { // if (response.details().size() == 0) { // return ImmutableList.of(Integer.toString(response.code())); // } // // String[] lines = new String[response.details().size()]; // // for (int i = 0; i < response.details().size(); i++) { // StringBuilder responseBuilder = new StringBuilder(); // // responseBuilder.append(response.code()); // // if (i == response.details().size() - 1) { // responseBuilder.append(" "); // } else { // responseBuilder.append("-"); // } // // responseBuilder.append(response.details().get(i)); // // lines[i] = responseBuilder.toString(); // } // // return ImmutableList.copyOf(lines); // } // // public static boolean isTransientError(SmtpResponse response) { // return response.code() >= 400 && response.code() < 500; // } // // public static boolean isPermanentError(SmtpResponse response) { // return response.code() >= 500; // } // // public static boolean isError(SmtpResponse response) { // return isTransientError(response) || isPermanentError(response); // } // } // Path: src/main/java/com/hubspot/smtp/client/NoopErrorResponseException.java import com.hubspot.smtp.utils.SmtpResponses; import io.netty.handler.codec.smtp.SmtpResponse; package com.hubspot.smtp.client; /** * Unchecked exception thrown when an error was received in response to a NOOP command. * */ public class NoopErrorResponseException extends SmtpException { public NoopErrorResponseException(String connectionId, SmtpResponse response, String message) {
super(connectionId, String.format("%s (%s)", message, SmtpResponses.toString(response)));
HubSpot/NioSmtpClient
src/main/java/com/hubspot/smtp/client/KeepAliveHandler.java
// Path: src/main/java/com/hubspot/smtp/utils/SmtpResponses.java // public final class SmtpResponses { // private static final Joiner SPACE_JOINER = Joiner.on(" ").skipNulls(); // // private SmtpResponses() { // throw new AssertionError("Cannot create static utility class"); // } // // public static String toString(SmtpResponse response) { // if (response.details().size() == 0) { // return Integer.toString(response.code()); // } else { // return response.code() + " " + SPACE_JOINER.join(response.details()); // } // } // // public static List<String> getLines(SmtpResponse response) { // if (response.details().size() == 0) { // return ImmutableList.of(Integer.toString(response.code())); // } // // String[] lines = new String[response.details().size()]; // // for (int i = 0; i < response.details().size(); i++) { // StringBuilder responseBuilder = new StringBuilder(); // // responseBuilder.append(response.code()); // // if (i == response.details().size() - 1) { // responseBuilder.append(" "); // } else { // responseBuilder.append("-"); // } // // responseBuilder.append(response.details().get(i)); // // lines[i] = responseBuilder.toString(); // } // // return ImmutableList.copyOf(lines); // } // // public static boolean isTransientError(SmtpResponse response) { // return response.code() >= 400 && response.code() < 500; // } // // public static boolean isPermanentError(SmtpResponse response) { // return response.code() >= 500; // } // // public static boolean isError(SmtpResponse response) { // return isTransientError(response) || isPermanentError(response); // } // }
import java.time.Duration; import java.util.List; import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.common.collect.Lists; import com.hubspot.smtp.utils.SmtpResponses; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; import io.netty.handler.codec.smtp.DefaultSmtpRequest; import io.netty.handler.codec.smtp.SmtpCommand; import io.netty.handler.codec.smtp.SmtpResponse; import io.netty.handler.timeout.IdleStateEvent; import io.netty.handler.timeout.IdleStateHandler;
KeepAliveHandler(ResponseHandler responseHandler, String connectionId, Duration idleTimeout) { // just track overall idle time; disable individual reader & writer timers by passing zero super(0, 0, Math.toIntExact(idleTimeout.getSeconds())); this.responseHandler = responseHandler; this.connectionId = connectionId; } @Override protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) throws Exception { LOG.debug("[{}] Sending NOOP to keep the connection alive", connectionId); if (expectingNoopResponse) { LOG.warn("[{}] Did not receive a response to our last NOOP, will not send another", connectionId); return; } Optional<String> debugString = responseHandler.getPendingResponseDebugString(); if (debugString.isPresent()) { LOG.warn("[{}] Waiting for a response to [{}], will not send a NOOP to keep the connection alive", connectionId, debugString.get()); } else { LOG.debug("[{}] Sending NOOP", connectionId); ctx.channel().writeAndFlush(new DefaultSmtpRequest(SmtpCommand.NOOP)); expectingNoopResponse = true; } } @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (expectingNoopResponse && msg instanceof SmtpResponse) {
// Path: src/main/java/com/hubspot/smtp/utils/SmtpResponses.java // public final class SmtpResponses { // private static final Joiner SPACE_JOINER = Joiner.on(" ").skipNulls(); // // private SmtpResponses() { // throw new AssertionError("Cannot create static utility class"); // } // // public static String toString(SmtpResponse response) { // if (response.details().size() == 0) { // return Integer.toString(response.code()); // } else { // return response.code() + " " + SPACE_JOINER.join(response.details()); // } // } // // public static List<String> getLines(SmtpResponse response) { // if (response.details().size() == 0) { // return ImmutableList.of(Integer.toString(response.code())); // } // // String[] lines = new String[response.details().size()]; // // for (int i = 0; i < response.details().size(); i++) { // StringBuilder responseBuilder = new StringBuilder(); // // responseBuilder.append(response.code()); // // if (i == response.details().size() - 1) { // responseBuilder.append(" "); // } else { // responseBuilder.append("-"); // } // // responseBuilder.append(response.details().get(i)); // // lines[i] = responseBuilder.toString(); // } // // return ImmutableList.copyOf(lines); // } // // public static boolean isTransientError(SmtpResponse response) { // return response.code() >= 400 && response.code() < 500; // } // // public static boolean isPermanentError(SmtpResponse response) { // return response.code() >= 500; // } // // public static boolean isError(SmtpResponse response) { // return isTransientError(response) || isPermanentError(response); // } // } // Path: src/main/java/com/hubspot/smtp/client/KeepAliveHandler.java import java.time.Duration; import java.util.List; import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.common.collect.Lists; import com.hubspot.smtp.utils.SmtpResponses; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; import io.netty.handler.codec.smtp.DefaultSmtpRequest; import io.netty.handler.codec.smtp.SmtpCommand; import io.netty.handler.codec.smtp.SmtpResponse; import io.netty.handler.timeout.IdleStateEvent; import io.netty.handler.timeout.IdleStateHandler; KeepAliveHandler(ResponseHandler responseHandler, String connectionId, Duration idleTimeout) { // just track overall idle time; disable individual reader & writer timers by passing zero super(0, 0, Math.toIntExact(idleTimeout.getSeconds())); this.responseHandler = responseHandler; this.connectionId = connectionId; } @Override protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) throws Exception { LOG.debug("[{}] Sending NOOP to keep the connection alive", connectionId); if (expectingNoopResponse) { LOG.warn("[{}] Did not receive a response to our last NOOP, will not send another", connectionId); return; } Optional<String> debugString = responseHandler.getPendingResponseDebugString(); if (debugString.isPresent()) { LOG.warn("[{}] Waiting for a response to [{}], will not send a NOOP to keep the connection alive", connectionId, debugString.get()); } else { LOG.debug("[{}] Sending NOOP", connectionId); ctx.channel().writeAndFlush(new DefaultSmtpRequest(SmtpCommand.NOOP)); expectingNoopResponse = true; } } @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (expectingNoopResponse && msg instanceof SmtpResponse) {
LOG.debug("[{}] NOOP response received {}", connectionId, SmtpResponses.toString((SmtpResponse) msg));
HubSpot/NioSmtpClient
src/main/java/com/hubspot/smtp/client/SmtpClientResponse.java
// Path: src/main/java/com/hubspot/smtp/utils/SmtpResponses.java // public final class SmtpResponses { // private static final Joiner SPACE_JOINER = Joiner.on(" ").skipNulls(); // // private SmtpResponses() { // throw new AssertionError("Cannot create static utility class"); // } // // public static String toString(SmtpResponse response) { // if (response.details().size() == 0) { // return Integer.toString(response.code()); // } else { // return response.code() + " " + SPACE_JOINER.join(response.details()); // } // } // // public static List<String> getLines(SmtpResponse response) { // if (response.details().size() == 0) { // return ImmutableList.of(Integer.toString(response.code())); // } // // String[] lines = new String[response.details().size()]; // // for (int i = 0; i < response.details().size(); i++) { // StringBuilder responseBuilder = new StringBuilder(); // // responseBuilder.append(response.code()); // // if (i == response.details().size() - 1) { // responseBuilder.append(" "); // } else { // responseBuilder.append("-"); // } // // responseBuilder.append(response.details().get(i)); // // lines[i] = responseBuilder.toString(); // } // // return ImmutableList.copyOf(lines); // } // // public static boolean isTransientError(SmtpResponse response) { // return response.code() >= 400 && response.code() < 500; // } // // public static boolean isPermanentError(SmtpResponse response) { // return response.code() >= 500; // } // // public static boolean isError(SmtpResponse response) { // return isTransientError(response) || isPermanentError(response); // } // }
import java.util.List; import java.util.stream.Collectors; import com.google.common.collect.ImmutableList; import com.hubspot.smtp.utils.SmtpResponses; import io.netty.handler.codec.smtp.SmtpResponse;
package com.hubspot.smtp.client; /** * Wraps the session and the responses to one or more SMTP commands. * * <p>This class is thread-safe. */ public class SmtpClientResponse { private final SmtpSession session; private final List<SmtpResponse> responses; public SmtpClientResponse(SmtpSession session, SmtpResponse response) { this.responses = ImmutableList.of(response); this.session = session; } public SmtpClientResponse(SmtpSession session, Iterable<SmtpResponse> responses) { this.responses = ImmutableList.copyOf(responses); this.session = session; } public SmtpClientResponse(SmtpSession session, List<SmtpResponse> responses) { this.responses = ImmutableList.copyOf(responses); this.session = session; } /** * Gets the {@link SmtpSession} that received these responses. */ public SmtpSession getSession() { return session; } /** * Gets whether any of the contained {@link SmtpResponse}s have a {@code code >= 400}. */ public boolean containsError() {
// Path: src/main/java/com/hubspot/smtp/utils/SmtpResponses.java // public final class SmtpResponses { // private static final Joiner SPACE_JOINER = Joiner.on(" ").skipNulls(); // // private SmtpResponses() { // throw new AssertionError("Cannot create static utility class"); // } // // public static String toString(SmtpResponse response) { // if (response.details().size() == 0) { // return Integer.toString(response.code()); // } else { // return response.code() + " " + SPACE_JOINER.join(response.details()); // } // } // // public static List<String> getLines(SmtpResponse response) { // if (response.details().size() == 0) { // return ImmutableList.of(Integer.toString(response.code())); // } // // String[] lines = new String[response.details().size()]; // // for (int i = 0; i < response.details().size(); i++) { // StringBuilder responseBuilder = new StringBuilder(); // // responseBuilder.append(response.code()); // // if (i == response.details().size() - 1) { // responseBuilder.append(" "); // } else { // responseBuilder.append("-"); // } // // responseBuilder.append(response.details().get(i)); // // lines[i] = responseBuilder.toString(); // } // // return ImmutableList.copyOf(lines); // } // // public static boolean isTransientError(SmtpResponse response) { // return response.code() >= 400 && response.code() < 500; // } // // public static boolean isPermanentError(SmtpResponse response) { // return response.code() >= 500; // } // // public static boolean isError(SmtpResponse response) { // return isTransientError(response) || isPermanentError(response); // } // } // Path: src/main/java/com/hubspot/smtp/client/SmtpClientResponse.java import java.util.List; import java.util.stream.Collectors; import com.google.common.collect.ImmutableList; import com.hubspot.smtp.utils.SmtpResponses; import io.netty.handler.codec.smtp.SmtpResponse; package com.hubspot.smtp.client; /** * Wraps the session and the responses to one or more SMTP commands. * * <p>This class is thread-safe. */ public class SmtpClientResponse { private final SmtpSession session; private final List<SmtpResponse> responses; public SmtpClientResponse(SmtpSession session, SmtpResponse response) { this.responses = ImmutableList.of(response); this.session = session; } public SmtpClientResponse(SmtpSession session, Iterable<SmtpResponse> responses) { this.responses = ImmutableList.copyOf(responses); this.session = session; } public SmtpClientResponse(SmtpSession session, List<SmtpResponse> responses) { this.responses = ImmutableList.copyOf(responses); this.session = session; } /** * Gets the {@link SmtpSession} that received these responses. */ public SmtpSession getSession() { return session; } /** * Gets whether any of the contained {@link SmtpResponse}s have a {@code code >= 400}. */ public boolean containsError() {
return responses.stream().anyMatch(SmtpResponses::isError);
HubSpot/NioSmtpClient
src/main/java/com/hubspot/smtp/client/ResponseException.java
// Path: src/main/java/com/hubspot/smtp/utils/SmtpResponses.java // public final class SmtpResponses { // private static final Joiner SPACE_JOINER = Joiner.on(" ").skipNulls(); // // private SmtpResponses() { // throw new AssertionError("Cannot create static utility class"); // } // // public static String toString(SmtpResponse response) { // if (response.details().size() == 0) { // return Integer.toString(response.code()); // } else { // return response.code() + " " + SPACE_JOINER.join(response.details()); // } // } // // public static List<String> getLines(SmtpResponse response) { // if (response.details().size() == 0) { // return ImmutableList.of(Integer.toString(response.code())); // } // // String[] lines = new String[response.details().size()]; // // for (int i = 0; i < response.details().size(); i++) { // StringBuilder responseBuilder = new StringBuilder(); // // responseBuilder.append(response.code()); // // if (i == response.details().size() - 1) { // responseBuilder.append(" "); // } else { // responseBuilder.append("-"); // } // // responseBuilder.append(response.details().get(i)); // // lines[i] = responseBuilder.toString(); // } // // return ImmutableList.copyOf(lines); // } // // public static boolean isTransientError(SmtpResponse response) { // return response.code() >= 400 && response.code() < 500; // } // // public static boolean isPermanentError(SmtpResponse response) { // return response.code() >= 500; // } // // public static boolean isError(SmtpResponse response) { // return isTransientError(response) || isPermanentError(response); // } // }
import java.util.List; import java.util.stream.Collectors; import com.hubspot.smtp.utils.SmtpResponses; import io.netty.handler.codec.smtp.SmtpResponse;
package com.hubspot.smtp.client; public class ResponseException extends RuntimeException { public ResponseException(Throwable cause, String debugString, List<SmtpResponse> responses) { super(createMessage(debugString, responses), cause); } private static String createMessage(String debugString, List<SmtpResponse> responses) { String responsesSoFar = responses.isEmpty() ? "<none>" :
// Path: src/main/java/com/hubspot/smtp/utils/SmtpResponses.java // public final class SmtpResponses { // private static final Joiner SPACE_JOINER = Joiner.on(" ").skipNulls(); // // private SmtpResponses() { // throw new AssertionError("Cannot create static utility class"); // } // // public static String toString(SmtpResponse response) { // if (response.details().size() == 0) { // return Integer.toString(response.code()); // } else { // return response.code() + " " + SPACE_JOINER.join(response.details()); // } // } // // public static List<String> getLines(SmtpResponse response) { // if (response.details().size() == 0) { // return ImmutableList.of(Integer.toString(response.code())); // } // // String[] lines = new String[response.details().size()]; // // for (int i = 0; i < response.details().size(); i++) { // StringBuilder responseBuilder = new StringBuilder(); // // responseBuilder.append(response.code()); // // if (i == response.details().size() - 1) { // responseBuilder.append(" "); // } else { // responseBuilder.append("-"); // } // // responseBuilder.append(response.details().get(i)); // // lines[i] = responseBuilder.toString(); // } // // return ImmutableList.copyOf(lines); // } // // public static boolean isTransientError(SmtpResponse response) { // return response.code() >= 400 && response.code() < 500; // } // // public static boolean isPermanentError(SmtpResponse response) { // return response.code() >= 500; // } // // public static boolean isError(SmtpResponse response) { // return isTransientError(response) || isPermanentError(response); // } // } // Path: src/main/java/com/hubspot/smtp/client/ResponseException.java import java.util.List; import java.util.stream.Collectors; import com.hubspot.smtp.utils.SmtpResponses; import io.netty.handler.codec.smtp.SmtpResponse; package com.hubspot.smtp.client; public class ResponseException extends RuntimeException { public ResponseException(Throwable cause, String debugString, List<SmtpResponse> responses) { super(createMessage(debugString, responses), cause); } private static String createMessage(String debugString, List<SmtpResponse> responses) { String responsesSoFar = responses.isEmpty() ? "<none>" :
String.join(",", responses.stream().map(SmtpResponses::toString).collect(Collectors.toList()));
HubSpot/NioSmtpClient
src/test/java/com/hubspot/smtp/ChunkingExtension.java
// Path: src/test/java/com/hubspot/smtp/ExtensibleNettyServer.java // static final String NETTY_CHANNEL = "netty channel";
import static com.hubspot.smtp.ExtensibleNettyServer.NETTY_CHANNEL; import java.io.IOException; import java.io.OutputStream; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.james.protocols.api.ProtocolSession; import org.apache.james.protocols.api.ProtocolSession.State; import org.apache.james.protocols.api.Request; import org.apache.james.protocols.api.Response; import org.apache.james.protocols.api.future.FutureResponseImpl; import org.apache.james.protocols.api.handler.CommandHandler; import org.apache.james.protocols.api.handler.ExtensibleHandler; import org.apache.james.protocols.api.handler.LineHandler; import org.apache.james.protocols.api.handler.WiringException; import org.apache.james.protocols.netty.HandlerConstants; import org.apache.james.protocols.smtp.MailAddress; import org.apache.james.protocols.smtp.MailEnvelopeImpl; import org.apache.james.protocols.smtp.SMTPResponse; import org.apache.james.protocols.smtp.SMTPRetCode; import org.apache.james.protocols.smtp.SMTPSession; import org.apache.james.protocols.smtp.core.esmtp.EhloExtension; import org.apache.james.protocols.smtp.dsn.DSNStatus; import org.apache.james.protocols.smtp.hook.Hook; import org.apache.james.protocols.smtp.hook.MessageHook; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.SimpleChannelUpstreamHandler; import com.google.common.collect.Lists;
package com.hubspot.smtp; public class ChunkingExtension implements EhloExtension, CommandHandler<SMTPSession>, ExtensibleHandler, Hook { private static final String MAIL_ENVELOPE = "mail envelope"; private static final String BDAT_HANDLER_NAME = "BDAT handler"; private static final Pattern BDAT_COMMAND_PATTERN = Pattern.compile("(?<size>[0-9]+)(?<last> LAST)?"); private static final Response DELIVERY_SYNTAX = new SMTPResponse(SMTPRetCode.SYNTAX_ERROR_ARGUMENTS, DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.DELIVERY_SYNTAX) + " Invalid syntax").immutable(); private List<MessageHook> messageHandlers; @Override public Response onCommand(SMTPSession session, Request request) { Matcher matcher = BDAT_COMMAND_PATTERN.matcher(request.getArgument()); if (!matcher.matches()) { return DELIVERY_SYNTAX; }
// Path: src/test/java/com/hubspot/smtp/ExtensibleNettyServer.java // static final String NETTY_CHANNEL = "netty channel"; // Path: src/test/java/com/hubspot/smtp/ChunkingExtension.java import static com.hubspot.smtp.ExtensibleNettyServer.NETTY_CHANNEL; import java.io.IOException; import java.io.OutputStream; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.james.protocols.api.ProtocolSession; import org.apache.james.protocols.api.ProtocolSession.State; import org.apache.james.protocols.api.Request; import org.apache.james.protocols.api.Response; import org.apache.james.protocols.api.future.FutureResponseImpl; import org.apache.james.protocols.api.handler.CommandHandler; import org.apache.james.protocols.api.handler.ExtensibleHandler; import org.apache.james.protocols.api.handler.LineHandler; import org.apache.james.protocols.api.handler.WiringException; import org.apache.james.protocols.netty.HandlerConstants; import org.apache.james.protocols.smtp.MailAddress; import org.apache.james.protocols.smtp.MailEnvelopeImpl; import org.apache.james.protocols.smtp.SMTPResponse; import org.apache.james.protocols.smtp.SMTPRetCode; import org.apache.james.protocols.smtp.SMTPSession; import org.apache.james.protocols.smtp.core.esmtp.EhloExtension; import org.apache.james.protocols.smtp.dsn.DSNStatus; import org.apache.james.protocols.smtp.hook.Hook; import org.apache.james.protocols.smtp.hook.MessageHook; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.SimpleChannelUpstreamHandler; import com.google.common.collect.Lists; package com.hubspot.smtp; public class ChunkingExtension implements EhloExtension, CommandHandler<SMTPSession>, ExtensibleHandler, Hook { private static final String MAIL_ENVELOPE = "mail envelope"; private static final String BDAT_HANDLER_NAME = "BDAT handler"; private static final Pattern BDAT_COMMAND_PATTERN = Pattern.compile("(?<size>[0-9]+)(?<last> LAST)?"); private static final Response DELIVERY_SYNTAX = new SMTPResponse(SMTPRetCode.SYNTAX_ERROR_ARGUMENTS, DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.DELIVERY_SYNTAX) + " Invalid syntax").immutable(); private List<MessageHook> messageHandlers; @Override public Response onCommand(SMTPSession session, Request request) { Matcher matcher = BDAT_COMMAND_PATTERN.matcher(request.getArgument()); if (!matcher.matches()) { return DELIVERY_SYNTAX; }
Channel channel = (Channel) session.getAttachment(NETTY_CHANNEL, State.Connection);
mikolajmitura/java-properties-to-json
src/main/java/pl/jalokim/propertiestojson/resolvers/primitives/string/TextToBooleanResolver.java
// Path: src/main/java/pl/jalokim/propertiestojson/resolvers/PrimitiveJsonTypesResolver.java // public class PrimitiveJsonTypesResolver extends JsonTypeResolver { // // private final List<TextToConcreteObjectResolver<?>> toObjectsResolvers; // private final JsonTypeResolversHierarchyResolver resolversHierarchyResolver; // private final Boolean skipNulls; // private final NullToJsonTypeConverter nullToJsonTypeConverter; // // public PrimitiveJsonTypesResolver(List<TextToConcreteObjectResolver<?>> toObjectsResolvers, // List<ObjectToJsonTypeConverter<?>> toJsonResolvers, // Boolean skipNulls, // NullToJsonTypeConverter nullToJsonTypeConverter) { // this.toObjectsResolvers = ImmutableList.copyOf(toObjectsResolvers); // this.resolversHierarchyResolver = new JsonTypeResolversHierarchyResolver(toJsonResolvers); // this.skipNulls = skipNulls; // this.nullToJsonTypeConverter = nullToJsonTypeConverter; // } // // @Override // public ObjectJsonType traverse(PathMetadata currentPathMetaData) { // addPrimitiveFieldWhenIsValid(currentPathMetaData); // return null; // } // // private void addPrimitiveFieldWhenIsValid(PathMetadata currentPathMetaData) { // JsonObjectFieldsValidator.checkThatFieldCanBeSet(currentObjectJsonType, currentPathMetaData, propertyKey); // addPrimitiveFieldToCurrentJsonObject(currentPathMetaData); // } // // private void addPrimitiveFieldToCurrentJsonObject(PathMetadata currentPathMetaData) { // String field = currentPathMetaData.getFieldName(); // if (currentPathMetaData.isArrayField()) { // addFieldToArray(currentPathMetaData); // } else { // if (currentObjectJsonType.containsField(field) && isArrayJson(currentObjectJsonType.getField(field))) { // AbstractJsonType abstractJsonType = currentPathMetaData.getJsonValue(); // ArrayJsonType currentArrayInObject = currentObjectJsonType.getJsonArray(field); // if (isArrayJson(abstractJsonType)) { // ArrayJsonType newArray = (ArrayJsonType) abstractJsonType; // List<AbstractJsonType> abstractJsonTypes = newArray.convertToListWithoutRealNull(); // for (int i = 0; i < abstractJsonTypes.size(); i++) { // currentArrayInObject.addElement(i, abstractJsonTypes.get(i), currentPathMetaData); // } // } else { // throw new CannotOverrideFieldException(currentPathMetaData.getCurrentFullPath(), currentArrayInObject, propertyKey); // } // } else { // currentObjectJsonType.addField(field, currentPathMetaData.getJsonValue(), currentPathMetaData); // } // } // } // // public Object getResolvedObject(String propertyValue, String propertyKey) { // Optional<?> objectOptional = Optional.empty(); // for (TextToConcreteObjectResolver primitiveResolver : toObjectsResolvers) { // if (!objectOptional.isPresent()) { // objectOptional = primitiveResolver.returnConvertedValueForClearedText(this, propertyValue, propertyKey); // } // } // return objectOptional.orElse(null); // } // // public AbstractJsonType resolvePrimitiveTypeAndReturn(Object propertyValue, String propertyKey) { // AbstractJsonType result; // if (propertyValue == null) { // result = nullToJsonTypeConverter.convertToJsonTypeOrEmpty(this, NULL_OBJECT, propertyKey).get(); // } else { // result = resolversHierarchyResolver.returnConcreteJsonTypeObject(this, propertyValue, propertyKey); // } // // if (Boolean.TRUE.equals(skipNulls) && result instanceof JsonNullReferenceType) { // result = SkipJsonField.SKIP_JSON_FIELD; // } // // return result; // } // // protected void addFieldToArray(PathMetadata currentPathMetaData) { // if (arrayWithGivenFieldNameExist(currentPathMetaData.getFieldName())) { // fetchArrayAndAddElement(currentPathMetaData); // } else { // createArrayAndAddElement(currentPathMetaData); // } // } // // private boolean arrayWithGivenFieldNameExist(String field) { // return currentObjectJsonType.containsField(field); // } // // private void createArrayAndAddElement(PathMetadata currentPathMetaData) { // ArrayJsonType arrayJsonTypeObject = new ArrayJsonType(); // addElementToArray(currentPathMetaData, arrayJsonTypeObject); // currentObjectJsonType.addField(currentPathMetaData.getFieldName(), arrayJsonTypeObject, currentPathMetaData); // } // // private void fetchArrayAndAddElement(PathMetadata currentPathMetaData) { // ArrayJsonType arrayJsonType = getArrayJsonWhenIsValid(currentPathMetaData); // addElementToArray(currentPathMetaData, arrayJsonType); // } // // private void addElementToArray(PathMetadata currentPathMetaData, ArrayJsonType arrayJsonTypeObject) { // arrayJsonTypeObject.addElement(currentPathMetaData.getPropertyArrayHelper(), currentPathMetaData.getJsonValue(), currentPathMetaData); // } // // }
import java.util.Optional; import pl.jalokim.propertiestojson.resolvers.PrimitiveJsonTypesResolver;
package pl.jalokim.propertiestojson.resolvers.primitives.string; public class TextToBooleanResolver implements TextToConcreteObjectResolver<Boolean> { private static final String TRUE = "true"; private static final String FALSE = "false"; private static Boolean getBoolean(String value) { return Boolean.valueOf(value); } @Override
// Path: src/main/java/pl/jalokim/propertiestojson/resolvers/PrimitiveJsonTypesResolver.java // public class PrimitiveJsonTypesResolver extends JsonTypeResolver { // // private final List<TextToConcreteObjectResolver<?>> toObjectsResolvers; // private final JsonTypeResolversHierarchyResolver resolversHierarchyResolver; // private final Boolean skipNulls; // private final NullToJsonTypeConverter nullToJsonTypeConverter; // // public PrimitiveJsonTypesResolver(List<TextToConcreteObjectResolver<?>> toObjectsResolvers, // List<ObjectToJsonTypeConverter<?>> toJsonResolvers, // Boolean skipNulls, // NullToJsonTypeConverter nullToJsonTypeConverter) { // this.toObjectsResolvers = ImmutableList.copyOf(toObjectsResolvers); // this.resolversHierarchyResolver = new JsonTypeResolversHierarchyResolver(toJsonResolvers); // this.skipNulls = skipNulls; // this.nullToJsonTypeConverter = nullToJsonTypeConverter; // } // // @Override // public ObjectJsonType traverse(PathMetadata currentPathMetaData) { // addPrimitiveFieldWhenIsValid(currentPathMetaData); // return null; // } // // private void addPrimitiveFieldWhenIsValid(PathMetadata currentPathMetaData) { // JsonObjectFieldsValidator.checkThatFieldCanBeSet(currentObjectJsonType, currentPathMetaData, propertyKey); // addPrimitiveFieldToCurrentJsonObject(currentPathMetaData); // } // // private void addPrimitiveFieldToCurrentJsonObject(PathMetadata currentPathMetaData) { // String field = currentPathMetaData.getFieldName(); // if (currentPathMetaData.isArrayField()) { // addFieldToArray(currentPathMetaData); // } else { // if (currentObjectJsonType.containsField(field) && isArrayJson(currentObjectJsonType.getField(field))) { // AbstractJsonType abstractJsonType = currentPathMetaData.getJsonValue(); // ArrayJsonType currentArrayInObject = currentObjectJsonType.getJsonArray(field); // if (isArrayJson(abstractJsonType)) { // ArrayJsonType newArray = (ArrayJsonType) abstractJsonType; // List<AbstractJsonType> abstractJsonTypes = newArray.convertToListWithoutRealNull(); // for (int i = 0; i < abstractJsonTypes.size(); i++) { // currentArrayInObject.addElement(i, abstractJsonTypes.get(i), currentPathMetaData); // } // } else { // throw new CannotOverrideFieldException(currentPathMetaData.getCurrentFullPath(), currentArrayInObject, propertyKey); // } // } else { // currentObjectJsonType.addField(field, currentPathMetaData.getJsonValue(), currentPathMetaData); // } // } // } // // public Object getResolvedObject(String propertyValue, String propertyKey) { // Optional<?> objectOptional = Optional.empty(); // for (TextToConcreteObjectResolver primitiveResolver : toObjectsResolvers) { // if (!objectOptional.isPresent()) { // objectOptional = primitiveResolver.returnConvertedValueForClearedText(this, propertyValue, propertyKey); // } // } // return objectOptional.orElse(null); // } // // public AbstractJsonType resolvePrimitiveTypeAndReturn(Object propertyValue, String propertyKey) { // AbstractJsonType result; // if (propertyValue == null) { // result = nullToJsonTypeConverter.convertToJsonTypeOrEmpty(this, NULL_OBJECT, propertyKey).get(); // } else { // result = resolversHierarchyResolver.returnConcreteJsonTypeObject(this, propertyValue, propertyKey); // } // // if (Boolean.TRUE.equals(skipNulls) && result instanceof JsonNullReferenceType) { // result = SkipJsonField.SKIP_JSON_FIELD; // } // // return result; // } // // protected void addFieldToArray(PathMetadata currentPathMetaData) { // if (arrayWithGivenFieldNameExist(currentPathMetaData.getFieldName())) { // fetchArrayAndAddElement(currentPathMetaData); // } else { // createArrayAndAddElement(currentPathMetaData); // } // } // // private boolean arrayWithGivenFieldNameExist(String field) { // return currentObjectJsonType.containsField(field); // } // // private void createArrayAndAddElement(PathMetadata currentPathMetaData) { // ArrayJsonType arrayJsonTypeObject = new ArrayJsonType(); // addElementToArray(currentPathMetaData, arrayJsonTypeObject); // currentObjectJsonType.addField(currentPathMetaData.getFieldName(), arrayJsonTypeObject, currentPathMetaData); // } // // private void fetchArrayAndAddElement(PathMetadata currentPathMetaData) { // ArrayJsonType arrayJsonType = getArrayJsonWhenIsValid(currentPathMetaData); // addElementToArray(currentPathMetaData, arrayJsonType); // } // // private void addElementToArray(PathMetadata currentPathMetaData, ArrayJsonType arrayJsonTypeObject) { // arrayJsonTypeObject.addElement(currentPathMetaData.getPropertyArrayHelper(), currentPathMetaData.getJsonValue(), currentPathMetaData); // } // // } // Path: src/main/java/pl/jalokim/propertiestojson/resolvers/primitives/string/TextToBooleanResolver.java import java.util.Optional; import pl.jalokim.propertiestojson.resolvers.PrimitiveJsonTypesResolver; package pl.jalokim.propertiestojson.resolvers.primitives.string; public class TextToBooleanResolver implements TextToConcreteObjectResolver<Boolean> { private static final String TRUE = "true"; private static final String FALSE = "false"; private static Boolean getBoolean(String value) { return Boolean.valueOf(value); } @Override
public Optional<Boolean> returnObjectWhenCanBeResolved(PrimitiveJsonTypesResolver primitiveJsonTypesResolver, String propertyValue, String propertyKey) {
mikolajmitura/java-properties-to-json
src/main/java/pl/jalokim/propertiestojson/resolvers/primitives/string/TextToEmptyStringResolver.java
// Path: src/main/java/pl/jalokim/propertiestojson/resolvers/PrimitiveJsonTypesResolver.java // public class PrimitiveJsonTypesResolver extends JsonTypeResolver { // // private final List<TextToConcreteObjectResolver<?>> toObjectsResolvers; // private final JsonTypeResolversHierarchyResolver resolversHierarchyResolver; // private final Boolean skipNulls; // private final NullToJsonTypeConverter nullToJsonTypeConverter; // // public PrimitiveJsonTypesResolver(List<TextToConcreteObjectResolver<?>> toObjectsResolvers, // List<ObjectToJsonTypeConverter<?>> toJsonResolvers, // Boolean skipNulls, // NullToJsonTypeConverter nullToJsonTypeConverter) { // this.toObjectsResolvers = ImmutableList.copyOf(toObjectsResolvers); // this.resolversHierarchyResolver = new JsonTypeResolversHierarchyResolver(toJsonResolvers); // this.skipNulls = skipNulls; // this.nullToJsonTypeConverter = nullToJsonTypeConverter; // } // // @Override // public ObjectJsonType traverse(PathMetadata currentPathMetaData) { // addPrimitiveFieldWhenIsValid(currentPathMetaData); // return null; // } // // private void addPrimitiveFieldWhenIsValid(PathMetadata currentPathMetaData) { // JsonObjectFieldsValidator.checkThatFieldCanBeSet(currentObjectJsonType, currentPathMetaData, propertyKey); // addPrimitiveFieldToCurrentJsonObject(currentPathMetaData); // } // // private void addPrimitiveFieldToCurrentJsonObject(PathMetadata currentPathMetaData) { // String field = currentPathMetaData.getFieldName(); // if (currentPathMetaData.isArrayField()) { // addFieldToArray(currentPathMetaData); // } else { // if (currentObjectJsonType.containsField(field) && isArrayJson(currentObjectJsonType.getField(field))) { // AbstractJsonType abstractJsonType = currentPathMetaData.getJsonValue(); // ArrayJsonType currentArrayInObject = currentObjectJsonType.getJsonArray(field); // if (isArrayJson(abstractJsonType)) { // ArrayJsonType newArray = (ArrayJsonType) abstractJsonType; // List<AbstractJsonType> abstractJsonTypes = newArray.convertToListWithoutRealNull(); // for (int i = 0; i < abstractJsonTypes.size(); i++) { // currentArrayInObject.addElement(i, abstractJsonTypes.get(i), currentPathMetaData); // } // } else { // throw new CannotOverrideFieldException(currentPathMetaData.getCurrentFullPath(), currentArrayInObject, propertyKey); // } // } else { // currentObjectJsonType.addField(field, currentPathMetaData.getJsonValue(), currentPathMetaData); // } // } // } // // public Object getResolvedObject(String propertyValue, String propertyKey) { // Optional<?> objectOptional = Optional.empty(); // for (TextToConcreteObjectResolver primitiveResolver : toObjectsResolvers) { // if (!objectOptional.isPresent()) { // objectOptional = primitiveResolver.returnConvertedValueForClearedText(this, propertyValue, propertyKey); // } // } // return objectOptional.orElse(null); // } // // public AbstractJsonType resolvePrimitiveTypeAndReturn(Object propertyValue, String propertyKey) { // AbstractJsonType result; // if (propertyValue == null) { // result = nullToJsonTypeConverter.convertToJsonTypeOrEmpty(this, NULL_OBJECT, propertyKey).get(); // } else { // result = resolversHierarchyResolver.returnConcreteJsonTypeObject(this, propertyValue, propertyKey); // } // // if (Boolean.TRUE.equals(skipNulls) && result instanceof JsonNullReferenceType) { // result = SkipJsonField.SKIP_JSON_FIELD; // } // // return result; // } // // protected void addFieldToArray(PathMetadata currentPathMetaData) { // if (arrayWithGivenFieldNameExist(currentPathMetaData.getFieldName())) { // fetchArrayAndAddElement(currentPathMetaData); // } else { // createArrayAndAddElement(currentPathMetaData); // } // } // // private boolean arrayWithGivenFieldNameExist(String field) { // return currentObjectJsonType.containsField(field); // } // // private void createArrayAndAddElement(PathMetadata currentPathMetaData) { // ArrayJsonType arrayJsonTypeObject = new ArrayJsonType(); // addElementToArray(currentPathMetaData, arrayJsonTypeObject); // currentObjectJsonType.addField(currentPathMetaData.getFieldName(), arrayJsonTypeObject, currentPathMetaData); // } // // private void fetchArrayAndAddElement(PathMetadata currentPathMetaData) { // ArrayJsonType arrayJsonType = getArrayJsonWhenIsValid(currentPathMetaData); // addElementToArray(currentPathMetaData, arrayJsonType); // } // // private void addElementToArray(PathMetadata currentPathMetaData, ArrayJsonType arrayJsonTypeObject) { // arrayJsonTypeObject.addElement(currentPathMetaData.getPropertyArrayHelper(), currentPathMetaData.getJsonValue(), currentPathMetaData); // } // // }
import java.util.Optional; import pl.jalokim.propertiestojson.resolvers.PrimitiveJsonTypesResolver;
package pl.jalokim.propertiestojson.resolvers.primitives.string; public class TextToEmptyStringResolver implements TextToConcreteObjectResolver<String> { public static final TextToEmptyStringResolver EMPTY_TEXT_RESOLVER = new TextToEmptyStringResolver(); private static final String EMPTY_VALUE = ""; @Override
// Path: src/main/java/pl/jalokim/propertiestojson/resolvers/PrimitiveJsonTypesResolver.java // public class PrimitiveJsonTypesResolver extends JsonTypeResolver { // // private final List<TextToConcreteObjectResolver<?>> toObjectsResolvers; // private final JsonTypeResolversHierarchyResolver resolversHierarchyResolver; // private final Boolean skipNulls; // private final NullToJsonTypeConverter nullToJsonTypeConverter; // // public PrimitiveJsonTypesResolver(List<TextToConcreteObjectResolver<?>> toObjectsResolvers, // List<ObjectToJsonTypeConverter<?>> toJsonResolvers, // Boolean skipNulls, // NullToJsonTypeConverter nullToJsonTypeConverter) { // this.toObjectsResolvers = ImmutableList.copyOf(toObjectsResolvers); // this.resolversHierarchyResolver = new JsonTypeResolversHierarchyResolver(toJsonResolvers); // this.skipNulls = skipNulls; // this.nullToJsonTypeConverter = nullToJsonTypeConverter; // } // // @Override // public ObjectJsonType traverse(PathMetadata currentPathMetaData) { // addPrimitiveFieldWhenIsValid(currentPathMetaData); // return null; // } // // private void addPrimitiveFieldWhenIsValid(PathMetadata currentPathMetaData) { // JsonObjectFieldsValidator.checkThatFieldCanBeSet(currentObjectJsonType, currentPathMetaData, propertyKey); // addPrimitiveFieldToCurrentJsonObject(currentPathMetaData); // } // // private void addPrimitiveFieldToCurrentJsonObject(PathMetadata currentPathMetaData) { // String field = currentPathMetaData.getFieldName(); // if (currentPathMetaData.isArrayField()) { // addFieldToArray(currentPathMetaData); // } else { // if (currentObjectJsonType.containsField(field) && isArrayJson(currentObjectJsonType.getField(field))) { // AbstractJsonType abstractJsonType = currentPathMetaData.getJsonValue(); // ArrayJsonType currentArrayInObject = currentObjectJsonType.getJsonArray(field); // if (isArrayJson(abstractJsonType)) { // ArrayJsonType newArray = (ArrayJsonType) abstractJsonType; // List<AbstractJsonType> abstractJsonTypes = newArray.convertToListWithoutRealNull(); // for (int i = 0; i < abstractJsonTypes.size(); i++) { // currentArrayInObject.addElement(i, abstractJsonTypes.get(i), currentPathMetaData); // } // } else { // throw new CannotOverrideFieldException(currentPathMetaData.getCurrentFullPath(), currentArrayInObject, propertyKey); // } // } else { // currentObjectJsonType.addField(field, currentPathMetaData.getJsonValue(), currentPathMetaData); // } // } // } // // public Object getResolvedObject(String propertyValue, String propertyKey) { // Optional<?> objectOptional = Optional.empty(); // for (TextToConcreteObjectResolver primitiveResolver : toObjectsResolvers) { // if (!objectOptional.isPresent()) { // objectOptional = primitiveResolver.returnConvertedValueForClearedText(this, propertyValue, propertyKey); // } // } // return objectOptional.orElse(null); // } // // public AbstractJsonType resolvePrimitiveTypeAndReturn(Object propertyValue, String propertyKey) { // AbstractJsonType result; // if (propertyValue == null) { // result = nullToJsonTypeConverter.convertToJsonTypeOrEmpty(this, NULL_OBJECT, propertyKey).get(); // } else { // result = resolversHierarchyResolver.returnConcreteJsonTypeObject(this, propertyValue, propertyKey); // } // // if (Boolean.TRUE.equals(skipNulls) && result instanceof JsonNullReferenceType) { // result = SkipJsonField.SKIP_JSON_FIELD; // } // // return result; // } // // protected void addFieldToArray(PathMetadata currentPathMetaData) { // if (arrayWithGivenFieldNameExist(currentPathMetaData.getFieldName())) { // fetchArrayAndAddElement(currentPathMetaData); // } else { // createArrayAndAddElement(currentPathMetaData); // } // } // // private boolean arrayWithGivenFieldNameExist(String field) { // return currentObjectJsonType.containsField(field); // } // // private void createArrayAndAddElement(PathMetadata currentPathMetaData) { // ArrayJsonType arrayJsonTypeObject = new ArrayJsonType(); // addElementToArray(currentPathMetaData, arrayJsonTypeObject); // currentObjectJsonType.addField(currentPathMetaData.getFieldName(), arrayJsonTypeObject, currentPathMetaData); // } // // private void fetchArrayAndAddElement(PathMetadata currentPathMetaData) { // ArrayJsonType arrayJsonType = getArrayJsonWhenIsValid(currentPathMetaData); // addElementToArray(currentPathMetaData, arrayJsonType); // } // // private void addElementToArray(PathMetadata currentPathMetaData, ArrayJsonType arrayJsonTypeObject) { // arrayJsonTypeObject.addElement(currentPathMetaData.getPropertyArrayHelper(), currentPathMetaData.getJsonValue(), currentPathMetaData); // } // // } // Path: src/main/java/pl/jalokim/propertiestojson/resolvers/primitives/string/TextToEmptyStringResolver.java import java.util.Optional; import pl.jalokim.propertiestojson.resolvers.PrimitiveJsonTypesResolver; package pl.jalokim.propertiestojson.resolvers.primitives.string; public class TextToEmptyStringResolver implements TextToConcreteObjectResolver<String> { public static final TextToEmptyStringResolver EMPTY_TEXT_RESOLVER = new TextToEmptyStringResolver(); private static final String EMPTY_VALUE = ""; @Override
public Optional<String> returnObjectWhenCanBeResolved(PrimitiveJsonTypesResolver primitiveJsonTypesResolver,