--- /dev/null
+/*
+ * 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;
+ }
+
+}
+++ /dev/null
-/*
- * 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;
- }
-
-}
--- /dev/null
+/*
+ * 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 ();
+
+}
+++ /dev/null
-/*
- * 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 ();
-
-}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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 ();
+
+}
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.