diff --git a/MedicinePublisherV1/.classpath b/MedicinePublisherV1/.classpath deleted file mode 100644 index eca7bdb..0000000 --- a/MedicinePublisherV1/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/MedicinePublisherV1/.project b/MedicinePublisherV1/.project deleted file mode 100644 index 6bc3522..0000000 --- a/MedicinePublisherV1/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - MedicinePublisherV1 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/MedicinePublisherV1/.settings/org.eclipse.jdt.core.prefs b/MedicinePublisherV1/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 0c68a61..0000000 --- a/MedicinePublisherV1/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/MedicinePublisherV1/.settings/org.eclipse.pde.core.prefs b/MedicinePublisherV1/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index f29e940..0000000 --- a/MedicinePublisherV1/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -pluginProject.extensions=false -resolve.requirebundle=false diff --git a/MedicinePublisherV1/META-INF/MANIFEST.MF b/MedicinePublisherV1/META-INF/MANIFEST.MF deleted file mode 100644 index 38dddfe..0000000 --- a/MedicinePublisherV1/META-INF/MANIFEST.MF +++ /dev/null @@ -1,11 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: MedicinePublisher -Bundle-SymbolicName: MedicinePublisher -Bundle-Version: 1.0.1.qualifier -Bundle-Activator: sa.assignment1.medicinepublisher.MedicineActivator -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Import-Package: org.osgi.framework;version="1.3.0", - sa.assignment1.DatabaseService -Bundle-ActivationPolicy: lazy -Export-Package: sa.assignment1.medicinepublisher diff --git a/MedicinePublisherV1/bin/sa/assignment1/medicinepublisher/MedicineActivator.class b/MedicinePublisherV1/bin/sa/assignment1/medicinepublisher/MedicineActivator.class deleted file mode 100644 index 6ccbff9..0000000 Binary files a/MedicinePublisherV1/bin/sa/assignment1/medicinepublisher/MedicineActivator.class and /dev/null differ diff --git a/MedicinePublisherV1/bin/sa/assignment1/medicinepublisher/MedicinePublish.class b/MedicinePublisherV1/bin/sa/assignment1/medicinepublisher/MedicinePublish.class deleted file mode 100644 index 438bb89..0000000 Binary files a/MedicinePublisherV1/bin/sa/assignment1/medicinepublisher/MedicinePublish.class and /dev/null differ diff --git a/MedicinePublisherV1/bin/sa/assignment1/medicinepublisher/MedicinePublishImpl.class b/MedicinePublisherV1/bin/sa/assignment1/medicinepublisher/MedicinePublishImpl.class deleted file mode 100644 index a1f7aa0..0000000 Binary files a/MedicinePublisherV1/bin/sa/assignment1/medicinepublisher/MedicinePublishImpl.class and /dev/null differ diff --git a/MedicinePublisherV1/build.properties b/MedicinePublisherV1/build.properties deleted file mode 100644 index 34d2e4d..0000000 --- a/MedicinePublisherV1/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/MedicinePublisherV1/src/sa/assignment1/medicinepublisher/MedicineActivator.java b/MedicinePublisherV1/src/sa/assignment1/medicinepublisher/MedicineActivator.java deleted file mode 100644 index fbe4952..0000000 --- a/MedicinePublisherV1/src/sa/assignment1/medicinepublisher/MedicineActivator.java +++ /dev/null @@ -1,46 +0,0 @@ -package sa.assignment1.medicinepublisher; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; - -import sa.assignment1.DatabaseService.MedicineDao; -import sa.assignment1.DatabaseService.MedicineDaoImpl; - -public class MedicineActivator implements BundleActivator { - - ServiceRegistration publishServiceRegistration; - - ServiceReference serviceReference; - - /* - * (non-Javadoc) - * - * @see org.osgi.framework.BundleActivator#start(org.osgi.framework. - * BundleContext) - */ - public void start(BundleContext context) throws Exception { - - serviceReference = context.getServiceReference(MedicineDao.class.getName()); - MedicineDao medicineDao = (MedicineDaoImpl) context.getService(serviceReference); - - System.out.println("Medicine Publisher Started !!!"); - MedicinePublish publisherService = new MedicinePublishImpl(medicineDao); - publishServiceRegistration = context.registerService(MedicinePublish.class.getName(), publisherService, null); - - } - - /* - * (non-Javadoc) - * - * @see - * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - System.out.println("Medicine Publisher Stoped !!!"); - publishServiceRegistration.unregister(); - context.ungetService(serviceReference); - } - -} diff --git a/MedicinePublisherV1/src/sa/assignment1/medicinepublisher/MedicinePublish.java b/MedicinePublisherV1/src/sa/assignment1/medicinepublisher/MedicinePublish.java deleted file mode 100644 index 3c16839..0000000 --- a/MedicinePublisherV1/src/sa/assignment1/medicinepublisher/MedicinePublish.java +++ /dev/null @@ -1,15 +0,0 @@ -package sa.assignment1.medicinepublisher; - -public interface MedicinePublish { - - public void add(); - - public void deduct(); - - public void increase(); - - public void get(); - - public void deleteById(); - -} diff --git a/MedicinePublisherV1/src/sa/assignment1/medicinepublisher/MedicinePublishImpl.java b/MedicinePublisherV1/src/sa/assignment1/medicinepublisher/MedicinePublishImpl.java deleted file mode 100644 index 2966cd3..0000000 --- a/MedicinePublisherV1/src/sa/assignment1/medicinepublisher/MedicinePublishImpl.java +++ /dev/null @@ -1,133 +0,0 @@ -package sa.assignment1.medicinepublisher; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Scanner; - -import sa.assignment1.DatabaseService.MedicineDao; - -public class MedicinePublishImpl implements MedicinePublish { - - MedicineDao medicineDao = null; - HashMap medicineModel = new HashMap<>(); - - public MedicinePublishImpl(MedicineDao medicineDao) { - this.medicineDao = medicineDao; - } - - @Override - public void add() { - Scanner scanner = new Scanner(System.in); - System.out.print("Enter medicine id : "); - medicineModel.put("medicineId", scanner.nextLine()); - System.out.print("Enter medicine name : "); - medicineModel.put("medicineName", scanner.nextLine()); - System.out.print("Enter medicine description : "); - medicineModel.put("medicineDescription", scanner.nextLine()); - System.out.print("Enter medicine quantity : "); - medicineModel.put("medicineQuantity", Integer.toString(scanner.nextInt())); - System.out.print("Enter medicine unit price : "); - medicineModel.put("unitPrice", Double.toString(scanner.nextDouble())); - - System.out.print(" "); - if (medicineDao.save(medicineModel)) { - System.out.println("Medicine added successfully !!! "); - } else { - System.out.println("Sorry something went wrong !!! "); - } - } - - @Override - public void deduct() { - Map data = new HashMap<>(); - Scanner scanner = new Scanner(System.in); - int currentQuantity = 0; - int newQuantity = 0; - - System.out.print("Enter medicine id : "); - String id = scanner.nextLine(); - System.out.print("Enter medicine quantity to reduce : "); - int quantity = scanner.nextInt(); - - data = medicineDao.findById(id); - - if (Objects.nonNull(data)) { - currentQuantity = Integer.parseInt(data.get("medicineQuantity")); - if (currentQuantity >= quantity) { - newQuantity = currentQuantity - quantity; - } - data.put("medicineQuantity", Integer.toString(newQuantity)); - - if (medicineDao.save(data)) { - System.out.println("New deduced sucessfully !"); - System.out.println(""); - } - } else { - System.out.println("No medicine record found !!!"); - System.out.println(""); - } - - } - - @Override - public void get() { - System.out.println("Enter medicine id: "); - Scanner scanner = new Scanner(System.in); - - String id = scanner.nextLine(); - Map data = medicineDao.findById(id); - - if (Objects.nonNull(data)) { - data.forEach((key, value) -> System.out.println(key + ":" + value)); - System.out.println(""); - } else { - System.out.println("No medicine record found !!!"); - System.out.println(""); - } - } - - @Override - public void deleteById() { - Scanner scanner = new Scanner(System.in); - System.out.print("Enter medicine id: "); - String id = scanner.nextLine(); - - if (medicineDao.deleteById(id)) { - System.out.println("Medicine id:" + id + " removed sucessfully !"); - System.out.println(""); - } else { - System.out.println("Medicine id:" + id + " not found !"); - System.out.println(""); - } - } - - @Override - public void increase() { - Scanner scanner = new Scanner(System.in); - Map data = new HashMap<>(); - int currentQuantity = 0; - int newQuantity = 0; - - System.out.print("Enter medicine id : "); - String id = scanner.nextLine(); - System.out.print("Enter medicine quantity to increase: "); - int quantity = scanner.nextInt(); - - data = medicineDao.findById(id); - - if (medicineDao.deleteById(id)) { - currentQuantity = Integer.parseInt(data.get("medicineQuantity")); - newQuantity = currentQuantity + quantity; - data.put("medicineQuantity", Integer.toString(newQuantity)); - - if (medicineDao.save(data)) { - System.out.println("New increased sucessfully !"); - System.out.println(""); - } - } else { - System.out.println("Medicine id:" + id + " not found !"); - System.out.println(""); - } - } -}