📄 abstractentitynotificationmanagerejb.java
字号:
/*
* Copyright 2006-2007 Queplix Corp.
*
* Licensed under the Queplix Public License, Version 1.1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.queplix.com/solutions/commercial-open-source/queplix-public-license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.queplix.qwoss.notification;
import javax.ejb.CreateException;
import com.queplix.core.jxb.entity.Entity;
import com.queplix.core.modules.config.ejb.EntityViewConfigManagerLocal;
import com.queplix.core.modules.config.ejb.EntityViewConfigManagerLocalHome;
import com.queplix.core.modules.config.ejb.FocusConfigManagerLocal;
import com.queplix.core.modules.config.ejb.FocusConfigManagerLocalHome;
import com.queplix.core.modules.eql.CompoundKey;
import com.queplix.core.modules.eql.error.EQLException;
import com.queplix.core.modules.jeo.ejb.JEOManagerLocal;
import com.queplix.core.modules.jeo.ejb.JEOManagerLocalHome;
import com.queplix.core.utils.JNDINames;
import com.queplix.core.utils.ejb.AbstractSessionEJB;
import com.queplix.core.integrator.security.LogonSession;
import com.queplix.core.integrator.security.User;
import com.queplix.core.integrator.security.SecurityHelper;
import com.queplix.core.integrator.security.WorkGroup;
import com.queplix.qwoss.utils.CustomJNDINames;
import com.queplix.qwoss.utils.ApplicationHelper;
/**
* Base class for Notification Manager EJBs.
* @author [ALB] Baranov Andrey
* @version $Revision: 1.4.2.1 $ $Date: 2005/12/20 16:43:05 $
*/
abstract class AbstractEntityNotificationManagerEJB extends AbstractSessionEJB {
// ================================================================== Fields
/** User logon session. */
protected LogonSession ls;
/** Base entity. */
protected Entity entity;
/** Primary key value object. */
protected CompoundKey key;
/** JEO Manager EJB local interface reference. */
protected JEOManagerLocal jeoManager;
// ========================================================= EJB API methods
/**
* Initializes EJB.
*
* @param ls LogonSession object
* @param entityName entity name
* @param pkey entity primary key
*/
public void init(LogonSession ls, String entityName, Long pkey, Integer type) {
// Check arguments.
if (ls == null) {
throw new IllegalStateException("Login session is NULL.");
}
if (pkey == null) {
throw new IllegalStateException("Primary key is NULL.");
}
this.ls = ls;
// Get entity.
EntityViewConfigManagerLocal local = (EntityViewConfigManagerLocal) getLocalObject(
JNDINames.EntityViewConfigManager,
EntityViewConfigManagerLocalHome.class);
entity = local.getEntityViewConfig(entityName);
// Make a primary key VO.
key = new CompoundKey();
key.addKey(String.valueOf(pkey));
if( type != null)
key.addKey(String.valueOf(type));
// Get JEO Manager EJB reference.
jeoManager = (JEOManagerLocal) getLocalObject(JNDINames.JEOManager,
JEOManagerLocalHome.class);
}
// ========================================================== Public methods
public abstract void doNotification();
// ======================================================= Protected methods
/**
* Loads the employee user by ID.
*
* @param employeeID user ID
* @return user value object
*/
protected User loadEmployee( Long employeeID ) {
try {
if( employeeID != null )
return ApplicationHelper.loadEmployee(ls, employeeID);
} catch( EQLException ex ) {
throwException( ex );
}
return null;
}
protected User loadUser( Long userID ) {
try {
if( userID != null )
return ApplicationHelper.loadUser(ls, userID);
} catch( EQLException ex ) {
throwException( ex );
}
return null;
}
/**
* Loads the customer mail by ID.
*
* @param customerID user ID
* @return String value object
*/
protected String loadCustomerMail( Long customerID ) {
try {
if( customerID != null )
return ApplicationHelper.loadCustomerMail(ls, customerID);
} catch( EQLException ex ) {
throwException( ex );
}
return null;
}
/**
* Loads the group by ID.
*
* @param groupID group ID
* @return group value object
*/
protected WorkGroup loadGroup( Long groupID ) {
try {
if( groupID != null )
return SecurityHelper.loadGroup(ls, groupID);
} catch( EQLException ex ) {
throwException( ex );
}
return null;
}
/**
* Notification Manager EJB local interface getter
* @return EJB local interface reference
*/
protected NotificationManagerLocal getNotificationManagerLocal() {
NotificationManagerLocalHome home = (NotificationManagerLocalHome) getLocalHome(
CustomJNDINames.NotificationManager,
NotificationManagerLocalHome.class);
try {
return home.create(ls, entity, key);
} catch (CreateException ex) {
throwException("Can't get NotificationManager local interface", ex);
return null;
}
}
/**
* FocusConfig Manager EJB local interface getter
* @return EJB local interface reference
*/
protected FocusConfigManagerLocal getFocusConfigManagerLocal() {
return (FocusConfigManagerLocal) getLocalObject(
JNDINames.FocusConfigManager, FocusConfigManagerLocalHome.class);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -