From: Roland Häder Date: Thu, 19 Jan 2023 05:11:08 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d5d99343583f2727d3b9b5fc3cc1f029239953a6;p=jjobs-war.git Continued: - added navigation rule for admin_list_skills view - fixed serial numbers --- diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java index ab2219d7..4c5f84e0 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java @@ -65,7 +65,7 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs /** * Serial number */ - private static final long serialVersionUID = 542_145_347_916L; + private static final long serialVersionUID = 542_145_351_001L; /** * Academic academicTitle diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java index 3523400f..833e3cae 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java @@ -65,7 +65,7 @@ public class JobsContactWebRequestBean extends BaseJobsBean implements JobsConta /** * Serial number */ - private static final long serialVersionUID = 542_145_347_916L; + private static final long serialVersionUID = 542_145_352_001L; /** * Academic academicTitle diff --git a/src/java/org/mxchange/jjobs/beans/contact/mobile/JobsContactMobileWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/mobile/JobsContactMobileWebRequestBean.java index f9d38187..5eb18db8 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/mobile/JobsContactMobileWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/mobile/JobsContactMobileWebRequestBean.java @@ -46,7 +46,7 @@ public class JobsContactMobileWebRequestBean extends BaseJobsBean implements Job /** * Serial number */ - private static final long serialVersionUID = 542_145_347_916L; + private static final long serialVersionUID = 542_145_353_001L; /** * An instance of a contact-list controller diff --git a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java index 668c181e..23a1b1c1 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java @@ -71,7 +71,7 @@ public class JobsAdminContactPhoneWebRequestBean extends BaseJobsBean implements /** * Serial number */ - private static final long serialVersionUID = 542_145_347_916L; + private static final long serialVersionUID = 542_145_354_001L; /** * Administrative EJB for phone number diff --git a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestBean.java index 833ff0ac..c5f11abc 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestBean.java @@ -48,7 +48,7 @@ public class JobsContactPhoneWebRequestBean extends BaseJobsBean implements Jobs /** * Serial number */ - private static final long serialVersionUID = 542_145_347_916L; + private static final long serialVersionUID = 542_145_355_001L; /** * An instance of a contact-list controller diff --git a/src/java/org/mxchange/jjobs/beans/jobs/skill/list/JobsSkillListWebViewBean.java b/src/java/org/mxchange/jjobs/beans/jobs/skill/list/JobsSkillListWebViewBean.java new file mode 100644 index 00000000..bbed97d7 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/jobs/skill/list/JobsSkillListWebViewBean.java @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2017 - 2022 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.beans.jobs.skill.list; + +import fish.payara.cdi.jsr107.impl.NamedCache; +import java.text.MessageFormat; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; +import javax.annotation.PostConstruct; +import javax.cache.Cache; +import javax.ejb.EJB; +import javax.enterprise.event.Observes; +import javax.faces.view.ViewScoped; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jjobs.beans.BaseJobsBean; +import org.mxchange.jjobs.events.skill.add.ObservableAdminAddedSkillEvent; +import org.mxchange.jjobs.model.exceptions.SkillNotFoundException; +import org.mxchange.jjobs.model.skill.SkillSessionBeanRemote; +import org.mxchange.jjobs.model.skill.Skillable; + +/** + * A view-scoped bean for product lists + *

+ * @author Roland Haeder + */ +@Named ("skillListController") +@ViewScoped +public class JobsSkillListWebViewBean extends BaseJobsBean implements JobsSkillListWebViewController { + + /** + * Serial number + */ + private static final long serialVersionUID = 34_869_872_672_645L; + + /** + * List of all basic company data + */ + private final List allSkills; + + /** + * List of filtered basic company data + */ + private List filteredSkills; + + /** + * Selected basic data + */ + private Skillable selectedSkill; + + /** + * EJB for general basic business data purposes + */ + @EJB (lookup = "java:global/jjobs-ejb/skill!org.mxchange.jjobs.model.skill.SkillSessionBeanRemote", description = "A stateless session bean for skills") + private SkillSessionBeanRemote skillBean; + + /** + * A list of all registered companies (globally) + */ + @Inject + @NamedCache (cacheName = "skillCache") + private transient Cache skillCache; + + /** + * Default constructor + */ + public JobsSkillListWebViewBean () { + // Call super constructor + super(); + + // Init list + this.allSkills = new LinkedList<>(); + } + + /** + * Observers events being fired when an administrator has added company + * basic data. + *

+ * @param event Event being fired + */ + public void afterAdminAddedBasicCompanyDataEvent (@Observes final ObservableAdminAddedSkillEvent event) { + // Is the parameter valid? + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getSkillable() == null) { + // Throw NPE again + throw new NullPointerException("event.skillableis null"); //NOI18N + } else if (event.getSkillable().getSkillId() == null) { + // Throw NPE again + throw new NullPointerException("event.skillable.skillId is null"); //NOI18N + } else if (event.getSkillable().getSkillId() < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("event.skillable.skillId={0} is invalid", event.getSkillable().getSkillId())); //NOI18N + } else if (event.getSkillable().getSkillName() == null) { + // Throw NPE again + throw new NullPointerException("event.skillable.skillName is null"); //NOI18N + } else if (event.getSkillable().getSkillName().isEmpty()) { + // Throw IAE again + throw new IllegalArgumentException("event.skillable.skillName is empty"); //NOI18N + } + + // Add it to list + this.skillCache.put(event.getSkillable().getSkillId(), event.getSkillable()); + this.getAllSkills().add(event.getSkillable()); + } + + @Override + public Skillable findSkillById (final Long skillId) throws SkillNotFoundException { + // Validate parameter + if (null == skillId) { + // Throw NPE + throw new NullPointerException("skillId is null"); //NOI18N + } else if (skillId < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("skillId={0} is invalid", skillId)); //NOI18N + } else if (!this.skillCache.containsKey(skillId)) { + // Not found + throw new SkillNotFoundException(skillId); + } + + // Get it from cache + final Skillable skill = this.skillCache.get(skillId); + + // Return it + return skill; + } + + /** + * Getter for a list of all business contacts + *

+ * @return A list of all business contacts + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getAllSkills () { + return this.allSkills; + } + + /** + * Getter for filtered basic company data + *

+ * @return Filtered basic company data + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getFilteredSkills () { + return this.filteredSkills; + } + + /** + * Setter for filtered basic company data + *

+ * @param filteredSkills Filtered basic company data + */ + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setFilteredSkills (final List filteredSkills) { + this.filteredSkills = filteredSkills; + } + + /** + * Getter for selected basic data + *

+ * @return Selected basic data + */ + public Skillable getSelectedSkill () { + return this.selectedSkill; + } + + /** + * Setter for selected basic data + *

+ * @param selectedSkill Selected basic data + */ + public void setSelectedSkill (final Skillable selectedSkill) { + this.selectedSkill = selectedSkill; + } + + /** + * Initializer method + */ + @PostConstruct + public void initializeList () { + // Is cache there? + if (!this.skillCache.iterator().hasNext()) { + // Add all + for (final Skillable skill : this.skillBean.fetchAllSkills()) { + // Add it to cache + this.skillCache.put(skill.getSkillId(), skill); + } + } + + // Is cache there and list is not full? + if ((this.getAllSkills().isEmpty()) && (this.skillCache.iterator().hasNext())) { + // Build up list + for (final Cache.Entry currentEntry : this.skillCache) { + // Add to list + this.getAllSkills().add(currentEntry.getValue()); + } + + // Sort list + this.getAllSkills().sort(new Comparator() { + @Override + public int compare (final Skillable skill1, final Skillable skill2) { + return skill1.getSkillId() > skill2.getSkillId() ? 1 : skill1.getSkillId() < skill2.getSkillId() ? -1 : 0; + } + }); + + // Set full list + this.setFilteredSkills(this.getAllSkills()); + } + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/jobs/skill/list/JobsSkillListWebViewController.java b/src/java/org/mxchange/jjobs/beans/jobs/skill/list/JobsSkillListWebViewController.java new file mode 100644 index 00000000..f7a3ab2d --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/jobs/skill/list/JobsSkillListWebViewController.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.beans.jobs.skill.list; + +import java.io.Serializable; +import org.mxchange.jjobs.model.exceptions.SkillNotFoundException; +import org.mxchange.jjobs.model.skill.Skillable; + +/** + * An interface of basic data list backing beans + *

+ * @author Roland Häder + */ +public interface JobsSkillListWebViewController extends Serializable { + + /** + * Retrieves a single skill entity for given id number or throws a proper + * exception if not found. + *

+ * @param skillId Company basic data id to lookup + *

+ * @return Skillinstance + *

+ * @throws SkillNotFoundException If the id number could not be looked up + * and solved into an entity + */ + Skillable findSkillById (final Long skillId) throws SkillNotFoundException; + +} diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java index b88acf8d..9e8fd2fb 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java @@ -78,7 +78,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm /** * Serial number */ - private static final long serialVersionUID = 542_145_347_916L; + private static final long serialVersionUID = 542_145_356_001L; /** * An event fired when the administrator has added a new user diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestBean.java index 21831a82..b5643b9e 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestBean.java @@ -32,7 +32,7 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR /** * Serial number */ - private static final long serialVersionUID = 542_145_347_916L; + private static final long serialVersionUID = 542_145_357_001L; /** * Default constructor diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index cc1c81a7..725957b0 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -168,6 +168,10 @@ admin_list_contact_mobile /admin/mobile/admin_contact_mobile_list.xhtml + + admin_list_skills + /admin/jobs/skill/admin_skill_list.xhtml + /user/login_index.xhtml diff --git a/web/WEB-INF/templates/admin/menu/project.tpl b/web/WEB-INF/templates/admin/menu/project.tpl index aa442752..2e51f98f 100644 --- a/web/WEB-INF/templates/admin/menu/project.tpl +++ b/web/WEB-INF/templates/admin/menu/project.tpl @@ -1,9 +1,11 @@ + xmlns:ui="http://xmlns.jcp.org/jsf/facelets" + xmlns:p="http://primefaces.org/ui" + > - + + + diff --git a/web/admin/jobs/skill/admin_skill_list.xhtml b/web/admin/jobs/skill/admin_skill_list.xhtml new file mode 100644 index 00000000..2b1bb172 --- /dev/null +++ b/web/admin/jobs/skill/admin_skill_list.xhtml @@ -0,0 +1,271 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +