/*
- * Copyright (C) 2016 - 2018 Free Software Foundation
+ * Copyright (C) 2016 - 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
import java.text.MessageFormat;
import java.util.Date;
+import java.util.Objects;
+import javax.ejb.EJB;
import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
-import org.mxchange.jjobs.database.BaseJobsDatabaseBean;
+import org.mxchange.jjobs.enterprise.BaseJobsEnterpriseBean;
/**
* An administrative contact EJB
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "adminContact", description = "An administrative contact EJB")
-public class JobsAdminContactSessionBean extends BaseJobsDatabaseBean implements AdminContactSessionBeanRemote {
+public class JobsAdminContactSessionBean extends BaseJobsEnterpriseBean implements AdminContactSessionBeanRemote {
/**
* Serial number
*/
private static final long serialVersionUID = 542_145_347_916L;
+ /**
+ * EJB for general contact purposes
+ */
+ @EJB (lookup = "java:global/jjobs-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote")
+ private ContactSessionBeanRemote contactBean;
+
/**
* Default constructor
*/
}
// Set created timestamp
- contact.setContactCreated(new Date());
+ contact.setContactEntryCreated(new Date());
// Set all created timestamps, if instance is there
this.setAllPhoneEntriesCreated(contact);
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isContactRegistered: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
- // Create query
- final Query query = this.getEntityManager().createNamedQuery("SearchContact"); //NOI18N
-
- // Set parameter
- query.setParameter("contact", contact); //NOI18N
- query.setMaxResults(1);
-
// Default is not found
boolean isFound = false;
- // Try it
- try {
- // Try to find instance
- final Contact dummy = (Contact) query.getSingleResult();
+ // Fest all entries and iterate over them
+ for (final Contact currentContact : this.contactBean.fetchAllContacts()) {
+ // Is found?
+ if (Objects.equals(contact, currentContact)) {
+ // Yes, found the same
+ isFound = true;
- // Mark as found
- isFound = true;
- } catch (final NoResultException e) {
- // No result found
+ // Abort loop
+ break;
+ }
}
// Trace message