Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/sales.git
src/main/java/com/whitemagicsoftware/sales/service/Loadable.java
-/*
- * The MIT License
- *
- * Copyright 2016 White Magic Software, Ltd..
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.whitemagicsoftware.sales.service;
-
-import java.util.List;
-
-/**
- * Used by services that can load information into a list.
- *
- * @author White Magic Software, Ltd.
- * @param <T> The type of loadable class to load.
- */
-public interface Loadable<T> {
- /**
- * Returns a list of items that have been loaded into memory.
- *
- * @return A non-null list.
- */
- public List<T> load();
-}
src/main/java/com/whitemagicsoftware/sales/service/ProductService.java
+/*
+ * The MIT License
+ *
+ * Copyright 2016 White Magic Software, Ltd..
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.whitemagicsoftware.sales.service;
+
+import com.whitemagicsoftware.sales.Product;
+import com.whitemagicsoftware.sales.Subscriber;
+import com.whitemagicsoftware.sales.Vendor;
+import java.util.List;
+
+/**
+ * Provides the ability to load product data.
+ *
+ * @author White Magic Software, Ltd.
+ */
+public interface ProductService extends Service {
+
+ /**
+ * Returns a list of products for a given subscriber and vendor.
+ *
+ * @param subscriber Person who has subscribed to products from a particular
+ * vendor.
+ * @param vendor The vendor that has products.
+ * @return
+ */
+ public List<Product> list(Subscriber subscriber, Vendor vendor);
+}
src/main/java/com/whitemagicsoftware/sales/service/impl/ProductServiceImpl.java
+/*
+ * The MIT License
+ *
+ * Copyright 2016 White Magic Software, Ltd..
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.whitemagicsoftware.sales.service.impl;
+
+import com.whitemagicsoftware.sales.Product;
+import com.whitemagicsoftware.sales.Subscriber;
+import com.whitemagicsoftware.sales.Vendor;
+import com.whitemagicsoftware.sales.service.ProductService;
+import java.util.List;
+
+/**
+ * @author White Magic Software, Ltd.
+ */
+public class ProductServiceImpl extends ServiceImpl<Product>
+ implements ProductService {
+
+ @Override
+ public List<Product> list(Subscriber subscriber, Vendor vendor) {
+ List<Product> result = createList();
+
+ Product product = new Product.Builder()
+ .withName("Sunflower Seeds")
+ .withUrlPath("sunflower-seeds/00000_000000000000005091")
+ .build();
+
+ result.add(product);
+
+ return result;
+ }
+
+}

Service-oriented architecture.

Author U-Dave-PC\Dave <email>
Date 2016-06-10 17:58:45 GMT-0700
Commit 3047fa3dd89d948d29e0508c3f498d013395e4ce
Parent 52ed713
Delta 99 lines added, 41 lines removed, 58-line increase