diff --git a/Api/src/main/java/edu/inventorym/Api.java b/Api/src/main/java/edu/inventorym/Api.java index c75b02c..069fe59 100644 --- a/Api/src/main/java/edu/inventorym/Api.java +++ b/Api/src/main/java/edu/inventorym/Api.java @@ -34,8 +34,6 @@ public interface Api { * is not already in the inventory before adding */ - InventoryManager.getInstance().getArtPieceTypes().forEach(System.out::println); - /* Add Inventory */ InventoryManager.getInstance().add(make(new Drawing())); @@ -45,17 +43,24 @@ public interface Api { InventoryManager.getInstance().add(make(new Sculpture())); InventoryManager.getInstance().add(make(new Sculpture())); + /* Add Customer */ + //CustomerManager.getInstance().add(new Customer("Kate", "Demsey", "310-676-4844", "kate@museum.com")); + //CustomerManager.getInstance().add(new Customer("Jim", "Gumbly", "203-676-4844", "jim@homedeco.com")); + CustomerManager.getInstance().load(); /* * 2. Remove art object from the inventory */ InventoryManager imgr = InventoryManager.getInstance(); - InventoryPiece art = imgr.find("####"); - imgr.Remove(art); + System.out.println(String.format("Art Pieces in INVENTORY: count %d", imgr.INVENTORY.size())); + InventoryPiece art = imgr.INVENTORY.getLast(); + InventoryPiece piece = imgr.find(art.getId()); + imgr.Remove(piece); + System.out.println(String.format("Removed 1 Art Pieces from INVENTORY: count %d", imgr.INVENTORY.size())); /* * 3. Return a list of all art objects from inventory */ CustomerManager cmgr = CustomerManager.getInstance(); - Customer customer = cmgr.findByEmail("kate@it.com"); + Customer customer = cmgr.findByEmail("kate@museum.com"); InventoryList customerCart = new InventoryList(); TransactionManager tmgr = TransactionManager.getInstance(); diff --git a/Api/src/resources/db/customers.json b/Api/src/resources/db/customers.json new file mode 100644 index 0000000..b95a5e3 --- /dev/null +++ b/Api/src/resources/db/customers.json @@ -0,0 +1,16 @@ +[ + { + "email": "kate@museum.com", + "id": "1039445606", + "nameFirst": "Kate", + "nameLast": "Demsey", + "phone": "310-676-4844" + }, + { + "email": "jim@homedeco.com", + "id": "4312148107", + "nameFirst": "Jim", + "nameLast": "Gumbly", + "phone": "203-676-4844" + } +] \ No newline at end of file diff --git a/Model/src/main/java/edu/inventorym/model/Customer.java b/Model/src/main/java/edu/inventorym/model/Customer.java index e5fc45e..9e4be81 100644 --- a/Model/src/main/java/edu/inventorym/model/Customer.java +++ b/Model/src/main/java/edu/inventorym/model/Customer.java @@ -20,10 +20,11 @@ public class Customer { this.nameLast = nameLast; this.phone = phone; this.email = email; + this.id = DataRepository.generateRandom10DigitID(); this.updated = ZonedDateTime.now(); } - public Customer(){} + protected Customer(){} public String getEmail() { return email; diff --git a/Model/src/main/java/edu/inventorym/model/CustomerManager.java b/Model/src/main/java/edu/inventorym/model/CustomerManager.java index f1b70be..a6aa80f 100644 --- a/Model/src/main/java/edu/inventorym/model/CustomerManager.java +++ b/Model/src/main/java/edu/inventorym/model/CustomerManager.java @@ -4,6 +4,8 @@ */ package edu.inventorym.model; +import java.io.IOException; + public class CustomerManager { final static CustomerManager INSTANCE = new CustomerManager(); @@ -28,6 +30,29 @@ public class CustomerManager { } public Customer findByEmail(String email){ + for (Customer c : CUSTOMERS) { + if (email.equalsIgnoreCase(c.getEmail())) { + return c; + } + } return null; } + + public void save() { + try { + DataRepository.write(this); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void load(){ + try { + DataRepository.read(this); + } catch (IOException e) { + e.printStackTrace(); + } catch(Exception e){ + e.printStackTrace(); + } + } } diff --git a/Model/src/main/java/edu/inventorym/model/DataRepository.java b/Model/src/main/java/edu/inventorym/model/DataRepository.java index b3f5888..82867d7 100644 --- a/Model/src/main/java/edu/inventorym/model/DataRepository.java +++ b/Model/src/main/java/edu/inventorym/model/DataRepository.java @@ -4,9 +4,18 @@ */ package edu.inventorym.model; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import java.io.StringReader; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.Paths; import java.security.SecureRandom; import java.util.ArrayList; import java.util.Base64; @@ -25,7 +34,7 @@ public class DataRepository { return INSTANCE; } - final public static String generateRandomID(int byteLength) { + final public static String generateRandomID(int byteLength) { SecureRandom secureRandom = new SecureRandom(); byte[] bytes = new byte[byteLength]; secureRandom.nextBytes(bytes); @@ -41,7 +50,7 @@ public class DataRepository { BigInteger val2 = randomCountLength.add(val1); return String.format("%010d", val2); } - + public static void WalkFileSystemTree(final InventoryManager manager) throws IOException { } @@ -51,84 +60,117 @@ public class DataRepository { public static void WalkFileSystemTree(final TransactionManager manager) throws IOException { } - - static void serialize_deserialize(){ + static void serialize_deserialize() { String jsonResponse = ""; - try{ - // Deserialize the JSON string to a Java RpcResponse object - Jsonb jsonb = JsonbBuilder.create(); - jsonResponse = jsonb.toJson((InventoryPiece)new Drawing()); + try { + // Deserialize the JSON string to a Java RpcResponse object + Jsonb jsonb = JsonbBuilder.create(); + jsonResponse = jsonb.toJson((InventoryPiece) new Drawing()); - System.out.println("json string: " + jsonResponse); + System.out.println("json string: " + jsonResponse); + InventoryPiece response = jsonb.fromJson(jsonResponse, Drawing.class); - InventoryPiece response = jsonb.fromJson(jsonResponse, Drawing.class); + System.out.println("Result: " + response); + System.out.println("ID: " + response.getId()); - System.out.println("Result: " + response); - System.out.println("ID: " + response.getId()); - - }catch(Exception e){ - e.printStackTrace(); - } - - try{ - // Configure pretty-printing and other settings - JsonbConfig config = new JsonbConfig() - .withFormatting(true); // Enable pretty-printing - Jsonb jsonb = JsonbBuilder.create(config); - - // Serialize using the custom configuration - String prettyJsonString = jsonb.toJson(new Drawing()); - - System.out.println("json string: " + prettyJsonString); - - }catch(Exception e){ + } catch (Exception e) { e.printStackTrace(); } try { - List rpcs = new ArrayList(); - rpcs.add(new Drawing()); - rpcs.add(new Drawing()); - rpcs.add(new Drawing()); + // Configure pretty-printing and other settings + JsonbConfig config = new JsonbConfig() + .withFormatting(true); // Enable pretty-printing + Jsonb jsonb = JsonbBuilder.create(config); - // Create Jsonb and serialize - Jsonb jsonb = JsonbBuilder.create(); - String result = jsonb.toJson(rpcs); + // Serialize using the custom configuration + String prettyJsonString = jsonb.toJson(new Drawing()); - - // Deserialize back - rpcs = jsonb.fromJson(result, - new ArrayList() {} - .getClass() - .getGenericSuperclass()); - - System.out.println( rpcs ); + System.out.println("json string: " + prettyJsonString); } catch (Exception e) { e.printStackTrace(); + } + + try { + List rpcs = new ArrayList(); + rpcs.add(new Drawing()); + rpcs.add(new Drawing()); + rpcs.add(new Drawing()); + + // Create Jsonb and serialize + Jsonb jsonb = JsonbBuilder.create(); + String result = jsonb.toJson(rpcs); + + // Deserialize back + rpcs = jsonb.fromJson(result, + new ArrayList() { + } + .getClass() + .getGenericSuperclass()); + + System.out.println(rpcs); + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + public static List mapJsonToObjectList(String body, Class baseClass) throws Exception { + try (var reader = Json.createReader(new StringReader(body)); + Jsonb jsonb = JsonbBuilder.create()) { + JsonArray jsonArray = reader.readArray(); + + return jsonArray.stream() + .map(jsonValue -> jsonb.fromJson(jsonValue.toString(), baseClass)) + .toList(); } - } - public static List mapJsonToObjectList(String body, Class baseClass) { - try (var reader = Json.createReader(new StringReader(body)); - Jsonb jsonb = JsonbBuilder.create()){ - JsonArray jsonArray = reader.readArray(); + static void write(CustomerManager mgr) throws IOException{ + JsonbConfig config = new JsonbConfig() + .withFormatting(true); // Enable pretty-printing + Jsonb jsonb = JsonbBuilder.create(config); + String result = jsonb.toJson(mgr.CUSTOMERS); - return jsonArray.stream() - .map(jsonValue -> jsonb.fromJson(jsonValue.toString(), baseClass)) - .toList(); - } catch (Exception e) { - return (List) new ArrayList(); + + String dataRoot = getRepositoryConfig.getPath(); + dataRoot = dataRoot + "/customers.json"; + Path path = Paths.get(dataRoot); + try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) { + writer.write(result); + writer.flush(); + } + } + + public static void read(CustomerManager customerManager) throws IOException, Exception { + String dataRoot = getRepositoryConfig.getPath(); + dataRoot = dataRoot + "/customers.json"; + Path path = Paths.get(dataRoot); + String result; + try (BufferedReader in = new BufferedReader(new FileReader(path.toFile(), StandardCharsets.UTF_8))){ + result = in.readAllAsString(); + } + + List customers = mapJsonToObjectList(result, Customer.class); +/* Jsonb jsonb = JsonbBuilder.create(); + CustomerList customers = jsonb.fromJson(result, new CustomerList() { } + .getClass() + .getGenericSuperclass()); */ + customerManager.CUSTOMERS.clear(); + customerManager.CUSTOMERS.addAll(customers); } - + public final static class getRepositoryConfig { public final static String getPath() { String home = System.getenv("HOME") != null ? System.getenv("HOME") : System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH"); - return home.replace('\\', '/') + "/workspace/reservationsystem/src/resources/db"; + return home.replace('\\', '/') + "/workspace/inventorym/Api/src/resources/db"; } } + + } diff --git a/Model/src/main/java/edu/inventorym/model/Drawing.java b/Model/src/main/java/edu/inventorym/model/Drawing.java index ce8c45d..5deb6fb 100644 --- a/Model/src/main/java/edu/inventorym/model/Drawing.java +++ b/Model/src/main/java/edu/inventorym/model/Drawing.java @@ -11,6 +11,12 @@ public class Drawing extends InventoryPiece { public String category; public Drawing() { - super(InventoryType.DRAWING); + super(); } + + @Override + public float computePrice() { + return price; + } + } diff --git a/Model/src/main/java/edu/inventorym/model/InventoryManager.java b/Model/src/main/java/edu/inventorym/model/InventoryManager.java index 087eb7f..b0457a9 100644 --- a/Model/src/main/java/edu/inventorym/model/InventoryManager.java +++ b/Model/src/main/java/edu/inventorym/model/InventoryManager.java @@ -21,15 +21,17 @@ public class InventoryManager { private InventoryManager() { } - public Set getArtPieceTypes() { - return EnumSet.allOf(InventoryType.class); - } - public void add(InventoryPiece iPiece) { INVENTORY.add(iPiece); } public InventoryPiece find(String id) { + for (InventoryPiece iv : INVENTORY) { + if (iv.getId() == id) { + return iv; + } + } + return null; } @@ -40,7 +42,7 @@ public class InventoryManager { public void save() { } - public void loadAll(){ + public void loadAll() { try { DataRepository.WalkFileSystemTree(INSTANCE); } catch (IOException e) { @@ -49,11 +51,9 @@ public class InventoryManager { } } - public void Remove(InventoryPiece iPiece) { - - //int i = find(iPiece); - //INVENTORY.remove(i) - //*** multiple quantiies of iPiece */ + public InventoryPiece Remove(InventoryPiece iPiece) { + int i = INVENTORY.indexOf(iPiece); + return INVENTORY.remove(i); }; } diff --git a/Model/src/main/java/edu/inventorym/model/InventoryPiece.java b/Model/src/main/java/edu/inventorym/model/InventoryPiece.java index 7e28c49..29f5750 100644 --- a/Model/src/main/java/edu/inventorym/model/InventoryPiece.java +++ b/Model/src/main/java/edu/inventorym/model/InventoryPiece.java @@ -15,7 +15,7 @@ public abstract class InventoryPiece { public float price; public ZonedDateTime created; public String title; - + /** * max 500 characters */ @@ -23,23 +23,14 @@ public abstract class InventoryPiece { public String Author; - InventoryType iventoryType; - - public InventoryPiece(InventoryType iventoryType) { - this.iventoryType = iventoryType; - this.created = ZonedDateTime.now(); - this.id = DataRepository.generateRandom10DigitID(); - } - public InventoryPiece() { - } - - public Boolean isArt(InventoryPiece piece) { - return false; + this.created = ZonedDateTime.now(); + this.id = DataRepository.generateRandom10DigitID(); + this.price = 10.99F; } public String getType() { - return this.iventoryType.toString(); + return this.getClass().getSimpleName().toUpperCase(); }; public String getId() { @@ -89,4 +80,6 @@ public abstract class InventoryPiece { public void setAuthor(String author) { Author = author; } + + public abstract float computePrice(); } diff --git a/Model/src/main/java/edu/inventorym/model/InventoryType.java b/Model/src/main/java/edu/inventorym/model/InventoryType.java deleted file mode 100644 index 107674a..0000000 --- a/Model/src/main/java/edu/inventorym/model/InventoryType.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * license: GPLv3 - edu.inventorym -*/ -package edu.inventorym.model; - -public enum InventoryType { - PAINTING, DRAWING, PRINT, SCULPTURE -} diff --git a/Model/src/main/java/edu/inventorym/model/Painting.java b/Model/src/main/java/edu/inventorym/model/Painting.java index 2c75e79..9f816d6 100644 --- a/Model/src/main/java/edu/inventorym/model/Painting.java +++ b/Model/src/main/java/edu/inventorym/model/Painting.java @@ -5,14 +5,77 @@ package edu.inventorym.model; public class Painting extends InventoryPiece { - int height; + +int height; int width; String style; String technique; String category; - public Painting (){ - super(InventoryType.PAINTING); + public Painting(int height, int width) { + super(); + this.height = height; + this.width = width; + } + public Painting() { + super(); } + public int getHeight() { + return height; + } + + public void setHeight(int height) { + this.height = height; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width = width; + } + + public String getStyle() { + return style; + } + + public void setStyle(String style) { + this.style = style; + } + + public String getTechnique() { + return technique; + } + + public void setTechnique(String technique) { + this.technique = technique; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + @Override + public float computePrice() { + + int sqarea = height * width; + float additional = 0; + if (sqarea < 100) { + additional = 5.99F; + } + if (sqarea > 100 && sqarea < 300) { + additional = 10.99F; + } + if (sqarea > 300) { + additional = 15.99F; + } + return price + additional; + + } } diff --git a/Model/src/main/java/edu/inventorym/model/Print.java b/Model/src/main/java/edu/inventorym/model/Print.java index 1c07a5f..9aa3fc0 100644 --- a/Model/src/main/java/edu/inventorym/model/Print.java +++ b/Model/src/main/java/edu/inventorym/model/Print.java @@ -10,7 +10,7 @@ public class Print extends InventoryPiece { String category; public Print(){ - super(InventoryType.PRINT); + super(); } public Print(String openEditionType, String category) { @@ -33,4 +33,9 @@ public class Print extends InventoryPiece { public void setCategory(String category) { this.category = category; } + + @Override + public float computePrice() { + return price; + } } diff --git a/Model/src/main/java/edu/inventorym/model/Sculpture.java b/Model/src/main/java/edu/inventorym/model/Sculpture.java index 2b12ea6..9ee0448 100644 --- a/Model/src/main/java/edu/inventorym/model/Sculpture.java +++ b/Model/src/main/java/edu/inventorym/model/Sculpture.java @@ -9,8 +9,33 @@ public class Sculpture extends InventoryPiece { String material; float weight; - public Sculpture (){ - super(InventoryType.SCULPTURE); + public Sculpture(float weight) { + super(); + this.weight = weight; } + public Sculpture() { + super(); + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + + public float getWeight() { + return weight; + } + + public void setWeight(float weight) { + this.weight = weight; + } + + @Override + public float computePrice() { + return price + (weight * 0.20F); + } } diff --git a/Model/src/main/java/edu/inventorym/model/Transaction.java b/Model/src/main/java/edu/inventorym/model/Transaction.java index 91069ff..277654b 100644 --- a/Model/src/main/java/edu/inventorym/model/Transaction.java +++ b/Model/src/main/java/edu/inventorym/model/Transaction.java @@ -15,6 +15,7 @@ public class Transaction { String customerId; Address shipToAddress; InventoryList customerInventoryList; + float totalPrice = 0.0F; JsonArray attributes; public Transaction() { @@ -33,6 +34,38 @@ public class Transaction { return created; } + public String getCustomerId() { + return customerId; + } + + public Address getShipToAddress() { + return shipToAddress; + } + + public InventoryList getCustomerInventoryList() { + return customerInventoryList; + } + + public void setCustomerInventoryList(InventoryList customerInventoryList) { + this.customerInventoryList = customerInventoryList; + } + + public float getTotalPrice() { + return totalPrice; + } + + public void setTotalPrice(float totalPrice) { + this.totalPrice = totalPrice; + } + + public JsonArray getAttributes() { + return attributes; + } + + public void setAttributes(JsonArray attributes) { + this.attributes = attributes; + } + public void setCreated(ZonedDateTime created) { this.created = created; } @@ -45,5 +78,12 @@ public class Transaction { this.completed = completed; } + public void setShipToAddress(Address mailing) { + this.shipToAddress = mailing; + } + + public void setCustomerId(String id) { + this.customerId = id; + } } diff --git a/Model/src/main/java/edu/inventorym/model/TransactionManager.java b/Model/src/main/java/edu/inventorym/model/TransactionManager.java index c852fe0..df2570a 100644 --- a/Model/src/main/java/edu/inventorym/model/TransactionManager.java +++ b/Model/src/main/java/edu/inventorym/model/TransactionManager.java @@ -17,19 +17,23 @@ public class TransactionManager { public TransactionList TRANSACTIONS = new TransactionList(); public Transaction TransactRequest(Customer customer, InventoryList iPieces, Transaction transacted) { + transacted.setCustomerId(customer.getId()); + transacted.setShipToAddress(customer.getMailing()); + transacted.setCustomerInventoryList(iPieces); + compute(transacted); return transacted; } - public void compute(Transaction tran, TransactionOperationEnum operation) { - + public void complete(Transaction tran) { + tran.setCompleted(ZonedDateTime.now()); } public void compute(Transaction tran) { - - } - - public void complete(Transaction tran) { - + float price = 0.0F; + for (InventoryPiece piece : tran.customerInventoryList) { + price += piece.computePrice(); + } + tran.totalPrice = price; } public TransactionList findByCustomerEmail(String email) { @@ -49,8 +53,7 @@ public class TransactionManager { } public void save() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'save'"); + } } diff --git a/Model/src/main/java/edu/inventorym/model/TransactionOperationEnum.java b/Model/src/main/java/edu/inventorym/model/TransactionOperationEnum.java deleted file mode 100644 index dfd1238..0000000 --- a/Model/src/main/java/edu/inventorym/model/TransactionOperationEnum.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * license: GPLv3 - edu.inventorym -*/ -package edu.inventorym.model; - -public enum TransactionOperationEnum { - Completed, - Draft, - Pricing, - Removed, - Shipping -} - diff --git a/README.md b/README.md index 2b7a113..f93d1fe 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,16 @@ # inventorym -Inheritance: Shows inheritance relationships (Drawing, Painting, Print, Sculpture extending InventoryPiece) -Associations: Shows composition relationships (Customer has Address, Transaction has Address and InventoryList) Enumerations: InventoryType and TransactionOperationEnum -Exceptions: four application exception classes extend RuntimeException -Manager Classes: Singleton pattern managers with their collections -Collections: Custom list classes extending ArrayList - - -Abstract base class (InventoryPiece) with 4 concrete implementations (Drawing, Painting, Print, Sculpture) -Enumerations (InventoryType, TransactionOperationEnum) -Manager classes (Singleton pattern): InventoryManager, CustomerManager, TransactionManager -Model classes: Customer, Address, Transaction -Collection classes: InventoryList, CustomerList, TransactionList -Repository: DataRepository for persistence -Exception classes: 4 custom runtime exceptions +Exception Classes: Four custom exception types +Value Object: Address class +Customer Management: Customer, CustomerList, and CustomerManager +Inventory Management: Abstract InventoryPiece with concrete implementations (Drawing, Painting, Print, Sculpture), plus InventoryList and InventoryManager +Transaction Management: Transaction, TransactionList, and TransactionManager +Data Repository: Singleton DataRepository for data operations Relationships shown: -Inheritance (empty arrow heads) -Composition (diamond arrow heads) -Associations (open arrow heads) -Dependencies (dashed lines) \ No newline at end of file +Inheritance (hollow arrows) +Associations (regular arrows) +Composition (diamond arrows) +Dependencies (dashed arrows) \ No newline at end of file diff --git a/uml/classdiagram.dot b/uml/classdiagram.dot index a79dc99..2bc7439 100644 --- a/uml/classdiagram.dot +++ b/uml/classdiagram.dot @@ -72,8 +72,8 @@ digraph InventoryManagementSystem { TransactionManager -> TransactionList [arrowhead=diamond, label="TRANSACTIONS"]; // List contains relationships - InventoryList -> InventoryPiece [arrowhead=diamond, style=dashed, label="contains"]; - CustomerList -> Customer [arrowhead=diamond, style=dashed, label="contains"]; + InventoryList -> InventoryPiece [arrowhead=odiamond, style=dashed, label="contains 0..*"]; + CustomerList -> Customer [arrowhead=odiamond, style=dashed, label="contains 0..*"]; TransactionList -> Transaction [arrowhead=diamond, style=dashed, label="contains"]; // Manager relationships diff --git a/uml/classdiagram2.dot b/uml/classdiagram2.dot new file mode 100644 index 0000000..22dc860 --- /dev/null +++ b/uml/classdiagram2.dot @@ -0,0 +1,84 @@ +digraph InventorySystem { + // Graph settings + rankdir=TB; + node [shape=record, fontname="Arial", fontsize=10]; + edge [fontname="Arial", fontsize=9]; + + // Abstract Class + InventoryPiece [label="{InventoryPiece\n«abstract»|+ id : String\l+ price : float\l+ created : ZonedDateTime\l+ title : String\l+ description : String\l+ Author : String\l- iventoryType : InventoryType\l|+ InventoryPiece(InventoryType)\l+ InventoryPiece()\l+ isArt(InventoryPiece) : Boolean\l+ getType() : String\l+ getId() : String\l+ setId(String) : void\l+ getPrice() : float\l+ setPrice(float) : void\l+ getCreated() : ZonedDateTime\l+ setCreated(ZonedDateTime) : void\l+ getTitle() : String\l+ setTitle(String) : void\l+ getDescription() : String\l+ setDescription(String) : void\l+ getAuthor() : String\l+ setAuthor(String) : void\l}", style=filled, fillcolor=lightyellow]; + + // Concrete Classes extending InventoryPiece + Drawing [label="{Drawing|+ style : String\l+ technique : String\l+ category : String\l|+ Drawing()\l}"]; + Painting [label="{Painting|- height : int\l- width : int\l- style : String\l- technique : String\l- category : String\l|+ Painting()\l}"]; + Print [label="{Print|- openEditionType : String\l- category : String\l|+ Print()\l+ Print(String, String)\l+ getOpenEditionType() : String\l+ setOpenEditionType(String) : void\l+ getCategory() : String\l+ setCategory(String) : void\l}"]; + Sculpture [label="{Sculpture|- material : String\l- weight : float\l|+ Sculpture()\l}"]; + + // Enums + InventoryType [label="{«enumeration»\nInventoryType|PAINTING\lDRAWING\lPRINT\lSCULPTURE\l}", style=filled, fillcolor=lightblue]; + TransactionOperationEnum [label="{«enumeration»\nTransactionOperationEnum|Completed\lDraft\lPricing\lRemoved\lShipping\l}", style=filled, fillcolor=lightblue]; + + // Value Objects + Address [label="{Address|- street : String\l- city : String\l- state : String\l- zip : String\l|+ Address()\l+ Address(String, String, String, String)\l+ getStreet() : String\l+ setStreet(String) : void\l+ getCity() : String\l+ setCity(String) : void\l+ getState() : String\l+ setState(String) : void\l+ getZip() : String\l+ setZip(String) : void\l+ hashCode() : int\l+ equals(Object) : boolean\l+ toString() : String\l}"]; + + // Domain Classes + Customer [label="{Customer|# id : String\l# updated : ZonedDateTime\l- phone : String\l- mailing : Address\l- email : String\l- nameFirst : String\l- nameLast : String\l|+ Customer(String, String, String, String)\l+ Customer()\l+ getEmail() : String\l+ getId() : String\l+ setId(String) : void\l+ getPhone() : String\l+ setPhone(String) : void\l+ getMailing() : Address\l+ setMailing(Address) : void\l+ setEmail(String) : void\l+ getNameFirst() : String\l+ setNameFirst(String) : void\l+ getNameLast() : String\l+ setNameLast(String) : void\l}"]; + + Transaction [label="{Transaction|- id : String\l- created : ZonedDateTime\l- completed : ZonedDateTime\l- customerId : String\l- shipToAddress : Address\l- customerInventoryList : InventoryList\l- attributes : JsonArray\l|+ Transaction()\l+ getId() : String\l+ setId(String) : void\l+ getCreated() : ZonedDateTime\l+ setCreated(ZonedDateTime) : void\l+ getCompleted() : ZonedDateTime\l+ setCompleted(ZonedDateTime) : void\l}"]; + + // Collection Classes + InventoryList [label="{InventoryList|+ InventoryList()\l}", style=filled, fillcolor=lightgreen]; + CustomerList [label="{CustomerList|+ CustomerList()\l}", style=filled, fillcolor=lightgreen]; + TransactionList [label="{TransactionList|+ TransactionList()\l+ add(Transaction) : boolean\l}", style=filled, fillcolor=lightgreen]; + + // Manager Classes (Singletons) + InventoryManager [label="{«singleton»\nInventoryManager|- INSTANCE : InventoryManager\l+ INVENTORY : InventoryList\l|- InventoryManager()\l+ getInstance() : InventoryManager\l+ getArtPieceTypes() : Set\\l+ add(InventoryPiece) : void\l+ find(String) : InventoryPiece\l+ update(InventoryPiece) : InventoryPiece\l+ save() : void\l+ loadAll() : void\l+ Remove(InventoryPiece) : void\l}", style=filled, fillcolor=lightcoral]; + + CustomerManager [label="{«singleton»\nCustomerManager|- INSTANCE : CustomerManager\l+ CUSTOMERS : CustomerList\l|+ getInstance() : CustomerManager\l+ add(Customer) : boolean\l- check(Customer) : void\l+ findById(String) : Customer\l+ findByEmail(String) : Customer\l}", style=filled, fillcolor=lightcoral]; + + TransactionManager [label="{«singleton»\nTransactionManager|- INSTANCE : TransactionManager\l+ TRANSACTIONS : TransactionList\l|+ getInstance() : TransactionManager\l+ TransactRequest(Customer, InventoryList, Transaction) : Transaction\l+ compute(Transaction, TransactionOperationEnum) : void\l+ compute(Transaction) : void\l+ complete(Transaction) : void\l+ findByCustomerEmail(String) : TransactionList\l+ findByTransactionId(String) : TransactionList\l+ findByTransactionDate(ZonedDateTime) : TransactionList\l+ remove(Transaction) : void\l+ save() : void\l}", style=filled, fillcolor=lightcoral]; + + // Utility Class + DataRepository [label="{«singleton»\nDataRepository|- INSTANCE : DataRepository\l|+ getInstance() : DataRepository\l+ generateRandomID(int) : String\l+ generateRandom10DigitID() : String\l+ WalkFileSystemTree(InventoryManager) : void\l+ WalkFileSystemTree(CustomerManager) : void\l+ WalkFileSystemTree(TransactionManager) : void\l+ mapJsonToObjectList(String, Class\) : List\\l}", style=filled, fillcolor=lavender]; + + // Exception Classes + InvalidArtOperationException [label="{InvalidArtOperationException|+ InvalidArtOperationException(String)\l+ InvalidArtOperationException(String, Throwable)\l+ InvalidArtOperationException(Throwable)\l}", style=filled, fillcolor=pink]; + + InvalidRecordDataException [label="{InvalidRecordDataException|+ InvalidRecordDataException(String)\l+ InvalidRecordDataException(String, Throwable)\l+ InvalidRecordDataException(Throwable)\l}", style=filled, fillcolor=pink]; + + InvalidTransactionException [label="{InvalidTransactionException|+ InvalidTransactionException(String)\l+ InvalidTransactionException(String, Throwable)\l+ InvalidTransactionException(Throwable)\l}", style=filled, fillcolor=pink]; + + InvalidTransOperationException [label="{InvalidTransOperationException|+ InvalidTransOperationException(String)\l+ InvalidTransOperationException(String, Throwable)\l+ InvalidTransOperationException(Throwable)\l}", style=filled, fillcolor=pink]; + + // Inheritance relationships + InventoryPiece -> Drawing [dir=back, arrowtail=empty, label="extends"]; + InventoryPiece -> Painting [dir=back, arrowtail=empty, label="extends"]; + InventoryPiece -> Print [dir=back, arrowtail=empty, label="extends"]; + InventoryPiece -> Sculpture [dir=back, arrowtail=empty, label="extends"]; + + // Collection inheritance + InventoryList -> InventoryPiece [arrowhead=diamond, label="contains *"]; + CustomerList -> Customer [arrowhead=diamond, label="contains *"]; + TransactionList -> Transaction [arrowhead=diamond, label="contains *"]; + + // Composition relationships + Customer -> Address [arrowhead=diamond, label="mailing"]; + Transaction -> Address [arrowhead=diamond, label="shipToAddress"]; + Transaction -> InventoryList [arrowhead=diamond, label="customerInventoryList"]; + + // Manager aggregations + InventoryManager -> InventoryList [arrowhead=diamond, label="INVENTORY"]; + CustomerManager -> CustomerList [arrowhead=diamond, label="CUSTOMERS"]; + TransactionManager -> TransactionList [arrowhead=diamond, label="TRANSACTIONS"]; + + // Dependencies + InventoryPiece -> InventoryType [style=dashed, arrowhead=open, label="uses"]; + CustomerManager -> InvalidRecordDataException [style=dashed, arrowhead=open, label="throws"]; + TransactionManager -> TransactionOperationEnum [style=dashed, arrowhead=open, label="uses"]; + InventoryManager -> DataRepository [style=dashed, arrowhead=open, label="uses"]; + CustomerManager -> DataRepository [style=dashed, arrowhead=open, label="uses"]; + TransactionManager -> DataRepository [style=dashed, arrowhead=open, label="uses"]; + InventoryPiece -> DataRepository [style=dashed, arrowhead=open, label="uses"]; + TransactionManager -> Customer [style=dashed, arrowhead=open, label="uses"]; + TransactionManager -> InventoryList [style=dashed, arrowhead=open, label="uses"]; + DataRepository -> InventoryPiece [style=dashed, arrowhead=open, label="serializes"]; +} \ No newline at end of file