--- /dev/null
+/*
+ * Copyright (C) 2023 Roland Häder<roland@mxchange.org>
+ *
+ * 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.jjobs.events.skill.add;
+
+import java.text.MessageFormat;
+import org.mxchange.jjobs.model.skill.Skillable;
+
+/**
+ * An event being fired when an administrator has added a new skill
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class AdminAddedSkillEvent implements ObservableAdminAddedSkillEvent {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 14_785_787_174_600_001L;
+
+ /**
+ * Instance of added skillable
+ */
+ private final Skillable skillable;
+
+ /**
+ * Constrcutor with skill instance
+ * <p>
+ * @param skillable An instance of a Skillable class
+ */
+ public AdminAddedSkillEvent (final Skillable skillable) {
+ // Validate parameter
+ if (null == skillable) {
+ // Throw NPE
+ throw new NullPointerException("Parameter 'skillable' is null"); //NOI18N
+ } else if (skillable.getSkillId() == null) {
+ // Throw it again
+ throw new NullPointerException("skillable.skillId is null"); //NOI18N
+ } else if (skillable.getSkillId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("skillable.skillId={0} is invalid", skillable.getSkillId())); //NOI18N
+ }
+
+ // Set it here
+ this.skillable = skillable;
+ }
+
+ @Override
+ public Skillable getSkillable () {
+ return this.skillable;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2023 Roland Häder<roland@mxchange.org>
+ *
+ * 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.jjobs.events.skill.add;
+
+import java.io.Serializable;
+import org.mxchange.jjobs.model.skill.Skillable;
+
+/**
+ * An interface for events being fired when an administrator has added a skill
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableAdminAddedSkillEvent extends Serializable {
+
+ /**
+ * Getter for Skillable class field
+ * <p>
+ * @return An instance of a Skillable class
+ */
+ Skillable getSkillable ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2023 Roland Häder<roland@mxchange.org>
+ *
+ * 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.jjobs.model.exceptions;
+
+import java.text.MessageFormat;
+
+/**
+ * An exception thrown when a Skillable instance wasn't found
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class SkillNotFoundException extends Exception {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 42_895_928_956_700_001L;
+
+ /**
+ * Constructor with primary key
+ * <p>
+ * @param skillId Primary key
+ */
+ public SkillNotFoundException (final Long skillId) {
+ super(MessageFormat.format("Skill id {0} not found.", skillId)); //NOI18N
+ }
+
+}
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Table (
name = "skills"
)
+@NamedQueries (
+ @NamedQuery (name = "AllSkills", query = "SELECT s FROM skills AS s ORDER BY s.skillId")
+)
@SuppressWarnings ("PersistenceUnitPresent")
public class JobSkill implements Skillable {
* When this entry has been created
*/
@Basic (optional = false)
- @Column (name = "skill_created", nullable = false, updatable = false)
+ @Column (name = "skill_entry_created", nullable = false, updatable = false)
@Temporal (TemporalType.TIMESTAMP)
- private Date skillCreated;
+ private Date skillEntryCreated;
+
+ /**
+ * When this entry has been updated
+ */
+ @Column (name = "skill_entry_updated", insertable = false)
+ @Temporal (TemporalType.TIMESTAMP)
+ private Date skillEntryUpdated;
/**
* Id number (primary key)
@Column (name = "skill_status", nullable = false)
private SkillStatus skillStatus;
- /**
- * When this entry has been updated
- */
- @Column (name = "skill_updated", insertable = false)
- @Temporal (TemporalType.TIMESTAMP)
- private Date skillUpdated;
-
/**
* Default constructor, required for the JPA.
*/
@Override
@SuppressWarnings ("ReturnOfDateField")
- public Date getSkillCreated () {
- return this.skillCreated;
+ public Date getSkillEntryCreated () {
+ return this.skillEntryCreated;
}
@Override
@SuppressWarnings ("AssignmentToDateFieldFromParameter")
- public void setSkillCreated (final Date skillCreated) {
- this.skillCreated = skillCreated;
+ public void setSkillEntryCreated (final Date skillEntryCreated) {
+ this.skillEntryCreated = skillEntryCreated;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfDateField")
+ public Date getSkillEntryUpdated () {
+ return this.skillEntryUpdated;
+ }
+
+ @Override
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setSkillEntryUpdated (final Date skillEntryUpdated) {
+ this.skillEntryUpdated = skillEntryUpdated;
}
@Override
this.skillStatus = skillStatus;
}
- @Override
- @SuppressWarnings ("ReturnOfDateField")
- public Date getSkillUpdated () {
- return this.skillUpdated;
- }
-
- @Override
- @SuppressWarnings ("AssignmentToDateFieldFromParameter")
- public void setSkillUpdated (final Date skillUpdated) {
- this.skillUpdated = skillUpdated;
- }
-
@Override
public int hashCode () {
int hash = 7;
* <p>
* @return Skill created timestamp
*/
- Date getSkillCreated ();
+ Date getSkillEntryCreated ();
/**
* Setter for skill created timestamp
* <p>
* @param skillCreated Skill created timestamp
*/
- void setSkillCreated (final Date skillCreated);
+ void setSkillEntryCreated (final Date skillCreated);
/**
* Getter for skill updated timestamp
* <p>
* @return Skill updated timestamp
*/
- Date getSkillUpdated ();
+ Date getSkillEntryUpdated ();
/**
* Setter for skill updated timestamp
* <p>
* @param skillUpdated Skill updated timestamp
*/
- void setSkillUpdated (final Date skillUpdated);
+ void setSkillEntryUpdated (final Date skillUpdated);
/**
* Getter for skill last locked timestamp