]> git.mxchange.org Git - jcontacts-business-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 10 May 2020 03:28:22 +0000 (05:28 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 10 May 2020 03:46:33 +0000 (05:46 +0200)
- added utilities method copyDepartmentData()
- added AdminUpdatedDepartmentEvent class and interface
- renamed DepartmentAddedEvent to AdminDeaprtmentAddedEvent

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jcontactsbusiness/events/department/added/AdminDepartmentAddedEvent.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/events/department/added/DepartmentAddedEvent.java [deleted file]
src/org/mxchange/jcontactsbusiness/events/department/added/ObservableAdminDepartmentAddedEvent.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/events/department/added/ObservableDepartmentAddedEvent.java [deleted file]
src/org/mxchange/jcontactsbusiness/events/department/updated/AdminDepartmentUpdatedEvent.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/events/department/updated/ObservableAdminDepartmentUpdatedEvent.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/model/department/Departments.java

diff --git a/src/org/mxchange/jcontactsbusiness/events/department/added/AdminDepartmentAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/department/added/AdminDepartmentAddedEvent.java
new file mode 100644 (file)
index 0000000..1e29963
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2017 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.events.department.added;
+
+import java.text.MessageFormat;
+import org.mxchange.jcontactsbusiness.model.department.Department;
+
+/**
+ * An event being fired when a addedDepartment has been added
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class AdminDepartmentAddedEvent implements ObservableAdminDepartmentAddedEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 572_367_561_659_111L;
+
+       /**
+        * Branch office instance being added
+        */
+       private final Department addedDepartment;
+
+       /**
+        * Constructor with addedDepartment instance
+        * <p>
+        * @param addedDepartment Branch office instance
+        * <p>
+        * @throws NullPointerException If the parameter is null
+        */
+       public AdminDepartmentAddedEvent (final Department addedDepartment) {
+               // Check parameter
+               if (null == addedDepartment) {
+                       // Throw NPE
+                       throw new NullPointerException("addedDepartment is null"); //NOI18N
+               } else if (addedDepartment.getDepartmentId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("addedDepartment.departmentId is null"); //NOI18N
+               } else if (addedDepartment.getDepartmentId() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("addedDepartment.departmentId={0} is not valid", addedDepartment.getDepartmentId())); //NOI18N
+               }
+
+               // Set it
+               this.addedDepartment = addedDepartment;
+       }
+
+       @Override
+       public Department getAddedDepartment () {
+               return this.addedDepartment;
+       }
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/events/department/added/DepartmentAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/department/added/DepartmentAddedEvent.java
deleted file mode 100644 (file)
index 97de10d..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2017 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.events.department.added;
-
-import java.text.MessageFormat;
-import org.mxchange.jcontactsbusiness.model.department.Department;
-
-/**
- * An event being fired when a department has been added
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class DepartmentAddedEvent implements ObservableDepartmentAddedEvent {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 572_367_561_659_111L;
-
-       /**
-        * Branch office instance being added
-        */
-       private final Department department;
-
-       /**
-        * Constructor with department instance
-        * <p>
-        * @param department Branch office instance
-        * <p>
-        * @throws NullPointerException If the parameter is null
-        */
-       public DepartmentAddedEvent (final Department department) {
-               // Check parameter
-               if (null == department) {
-                       // Throw NPE
-                       throw new NullPointerException("department is null"); //NOI18N
-               } else if (department.getDepartmentId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("department.departmentId is null"); //NOI18N
-               } else if (department.getDepartmentId() < 1) {
-                       // Throw NPE again
-                       throw new NullPointerException(MessageFormat.format("department.departmentId={0} is not valid", department.getDepartmentId())); //NOI18N
-               }
-
-               // Set it
-               this.department = department;
-       }
-
-       @Override
-       public Department getDepartment () {
-               return this.department;
-       }
-
-}
diff --git a/src/org/mxchange/jcontactsbusiness/events/department/added/ObservableAdminDepartmentAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/department/added/ObservableAdminDepartmentAddedEvent.java
new file mode 100644 (file)
index 0000000..80653be
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2017 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.events.department.added;
+
+import java.io.Serializable;
+import org.mxchange.jcontactsbusiness.model.department.Department;
+
+/**
+ * An interface for events being fired when a department has been added by an
+ * administrator.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableAdminDepartmentAddedEvent extends Serializable {
+
+       /**
+        * Getter for added department instance
+        * <p>
+        * @return Added department instance
+        */
+       Department getAddedDepartment ();
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/events/department/added/ObservableDepartmentAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/department/added/ObservableDepartmentAddedEvent.java
deleted file mode 100644 (file)
index bbdae8c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2017 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.events.department.added;
-
-import java.io.Serializable;
-import org.mxchange.jcontactsbusiness.model.department.Department;
-
-/**
- * An interface for events being fired when a department has been added.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableDepartmentAddedEvent extends Serializable {
-
-       /**
-        * Getter for department instance
-        * <p>
-        * @return Department instance
-        */
-       Department getDepartment ();
-
-}
diff --git a/src/org/mxchange/jcontactsbusiness/events/department/updated/AdminDepartmentUpdatedEvent.java b/src/org/mxchange/jcontactsbusiness/events/department/updated/AdminDepartmentUpdatedEvent.java
new file mode 100644 (file)
index 0000000..682e3b8
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2017 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.events.department.updated;
+
+import java.text.MessageFormat;
+import org.mxchange.jcontactsbusiness.model.department.Department;
+
+/**
+ * An event being fired when a department has been added
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class AdminDepartmentUpdatedEvent implements ObservableAdminDepartmentUpdatedEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 572_367_561_659_115L;
+
+       /**
+        * Branch office instance being added
+        */
+       private final Department updatedDepartment;
+
+       /**
+        * Constructor with department instance
+        * <p>
+        * @param updatedDepartment Branch office instance
+        * <p>
+        * @throws NullPointerException If the parameter is null
+        */
+       public AdminDepartmentUpdatedEvent (final Department updatedDepartment) {
+               // Check parameter
+               if (null == updatedDepartment) {
+                       // Throw NPE
+                       throw new NullPointerException("department is null"); //NOI18N
+               } else if (updatedDepartment.getDepartmentId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("department.departmentId is null"); //NOI18N
+               } else if (updatedDepartment.getDepartmentId() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("department.departmentId={0} is not valid", updatedDepartment.getDepartmentId())); //NOI18N
+               }
+
+               // Set it
+               this.updatedDepartment = updatedDepartment;
+       }
+
+       @Override
+       public Department getUpdatedDepartment () {
+               return this.updatedDepartment;
+       }
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/events/department/updated/ObservableAdminDepartmentUpdatedEvent.java b/src/org/mxchange/jcontactsbusiness/events/department/updated/ObservableAdminDepartmentUpdatedEvent.java
new file mode 100644 (file)
index 0000000..60f95bd
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2017 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.events.department.updated;
+
+import java.io.Serializable;
+import org.mxchange.jcontactsbusiness.model.department.Department;
+
+/**
+ * An interface for events being fired when a department has been updated by an
+ * administrator.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableAdminDepartmentUpdatedEvent extends Serializable {
+
+       /**
+        * Getter for updated department instance
+        * <p>
+        * @return Updated department instance
+        */
+       Department getUpdatedDepartment ();
+
+}
index d0b955deb4eef6eebb3815bad9c4bc14e73179cc..6eae84296ddd22f0993b543a25b52364a2b2736e 100644 (file)
@@ -60,6 +60,35 @@ public class Departments implements Serializable {
                return department1.compareTo(department2);
        }
 
+       /**
+        * Copies all data from source department to target department.
+        * <p>
+        * @param sourceDepartment Source department
+        * @param targetDepartment Target department
+        */
+       public static void copyDepartmentData (final Department sourceDepartment, final Department targetDepartment) {
+               // Check that both parameters are not null
+               if (null == sourceDepartment) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceDepartment is null"); //NOI18N
+               } else if (null == targetDepartment) {
+                       // Throw NPE
+                       throw new NullPointerException("targetDepartment is null"); //NOI18N
+               } else if (Objects.equals(sourceDepartment, targetDepartment)) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("sourceDepartment and targetDepartment are the same"); //NOI18N
+               }
+
+               // Copy all fields
+               targetDepartment.setDepartmentBranchOffice(sourceDepartment.getDepartmentBranchOffice());
+               targetDepartment.setDepartmentCompany(sourceDepartment.getDepartmentCompany());
+               targetDepartment.setDepartmentHeadquarter(sourceDepartment.getDepartmentHeadquarter());
+               targetDepartment.setDepartmentI18nKey(sourceDepartment.getDepartmentI18nKey());
+               targetDepartment.setDepartmentId(sourceDepartment.getDepartmentId());
+               targetDepartment.setDepartmentLead(sourceDepartment.getDepartmentLead());
+               targetDepartment.setDepartmentUserOwner(sourceDepartment.getDepartmentUserOwner());
+       }
+
        /**
         * Checks if both departments are the same (entity) or if at least basic
         * company data and department name are matching.