package com.ibm.commerce.sample.commands;
import com.ibm.commerce.command.TaskCommand;
import com.ibm.commerce.user.objects.UserRegistryAccessBean;
import com.ibm.ejb.sample.XBonusEJBAccessBean;
public interface MyNewTaskCmd extends TaskCommand {
public String getInputUserName() ;
public void setInputUserName(String inputUserName) ;
public Integer getInputPoints() ;
public void setInputPoints(Integer inputPoints);
public String getGreetings();
public void setGreetings(String greetings);
public UserRegistryAccessBean getUserRegistryAccessBean() ;
public void setUserRegistryAccessBean(
UserRegistryAccessBean userRegistryAccessBean);
public String getFoundUserId();
public void setFoundUserId(String foundUserId);
public XBonusEJBAccessBean getXBonusEJBAccessBean() ;
public void setXBonusEJBAccessBean(XBonusEJBAccessBean xbonusAEJBccessBean);
public Integer getTotalBonusPoints() ;
public void setTotalBonusPoints(Integer totalBonusPoints);
public Integer getOldBonusPoints();
public void setOldBonusPoints(Integer oldBonusPoints);
}
package com.ibm.commerce.sample.commands;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.naming.NamingException;
import com.ibm.commerce.command.TaskCommandImpl;
import com.ibm.commerce.exception.ECException;
import com.ibm.commerce.user.objects.UserRegistryAccessBean;
import com.ibm.ejb.sample.XBonusEJBAccessBean;
public class MyNewTaskCmdImpl extends TaskCommandImpl implements MyNewTaskCmd {
String inputUserName;
Integer inputPoints;
String greetings;
UserRegistryAccessBean userRegistryAccessBean;
String foundUserId;
XBonusEJBAccessBean xbonusEJBAccessBean;
Integer totalBonusPoints;
Integer oldBonusPoints;
public XBonusEJBAccessBean getXBonusEJBAccessBean() {
return xbonusEJBAccessBean;
}
public void setXBonusEJBAccessBean(XBonusEJBAccessBean xbonusEJBAccessBean) {
this.xbonusEJBAccessBean = xbonusEJBAccessBean;
}
public Integer getTotalBonusPoints() {
return totalBonusPoints;
}
public void setTotalBonusPoints(Integer totalBonusPoints) {
this.totalBonusPoints = totalBonusPoints;
}
public Integer getOldBonusPoints() {
return oldBonusPoints;
}
public void setOldBonusPoints(Integer oldBonusPoints) {
this.oldBonusPoints = oldBonusPoints;
}
public UserRegistryAccessBean getUserRegistryAccessBean() {
return userRegistryAccessBean;
}
public void setUserRegistryAccessBean(
UserRegistryAccessBean userRegistryAccessBean) {
this.userRegistryAccessBean = userRegistryAccessBean;
}
public String getFoundUserId() {
return foundUserId;
}
public void setFoundUserId(String foundUserId) {
this.foundUserId = foundUserId;
}
public String getInputUserName() {
return inputUserName;
}
public void setInputUserName(String inputUserName) {
this.inputUserName = inputUserName;
}
public Integer getInputPoints() {
return inputPoints;
}
public void setInputPoints(Integer inputPoints) {
this.inputPoints = inputPoints;
}
public String getGreetings() {
return greetings;
}
public void setGreetings(String greetings) {
this.greetings = greetings;
}
@Override
public void performExecute() throws ECException {
// TODO Auto-generated method stub
super.performExecute();
setGreetings("Hello!!!" + getInputUserName());
int newBP = oldBonusPoints.intValue() + getInputPoints().intValue();
totalBonusPoints = new Integer(newBP);
xbonusEJBAccessBean.setBonusPoint(totalBonusPoints);
try {
xbonusEJBAccessBean.commitCopyHelper();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void validateParameters() throws ECException {
// TODO Auto-generated method stub
super.validateParameters();
if (userRegistryAccessBean != null) {
try {
setFoundUserId(userRegistryAccessBean.findByUserLogonId(
getInputUserName()).getUserId());
} catch (Exception e) {
// TODO: handle exception
}
} else {
try {
userRegistryAccessBean = new UserRegistryAccessBean();
userRegistryAccessBean = userRegistryAccessBean
.findByUserLogonId(getInputUserName());
setFoundUserId(userRegistryAccessBean.getUserId());
} catch (Exception e) {
e.printStackTrace();
}
}
if (xbonusEJBAccessBean != null) {
try {
setOldBonusPoints(xbonusEJBAccessBean.getBonusPoint());
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FinderException e) {
try {
xbonusEJBAccessBean = new XBonusEJBAccessBean(new Long(
getFoundUserId()));
xbonusEJBAccessBean.setBonusPoint(new Integer(0));
oldBonusPoints = new Integer(0);
} catch (Exception e2) {
// TODO: handle exception
}
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
try {
xbonusEJBAccessBean = new XBonusEJBAccessBean(new Long(
getFoundUserId()));
xbonusEJBAccessBean.setBonusPoint(new Integer(0));
oldBonusPoints = new Integer(0);
} catch (Exception e2) {
// TODO: handle exception
}
}
}
}
import com.ibm.commerce.command.TaskCommand;
import com.ibm.commerce.user.objects.UserRegistryAccessBean;
import com.ibm.ejb.sample.XBonusEJBAccessBean;
public interface MyNewTaskCmd extends TaskCommand {
public String getInputUserName() ;
public void setInputUserName(String inputUserName) ;
public Integer getInputPoints() ;
public void setInputPoints(Integer inputPoints);
public String getGreetings();
public void setGreetings(String greetings);
public UserRegistryAccessBean getUserRegistryAccessBean() ;
public void setUserRegistryAccessBean(
UserRegistryAccessBean userRegistryAccessBean);
public String getFoundUserId();
public void setFoundUserId(String foundUserId);
public XBonusEJBAccessBean getXBonusEJBAccessBean() ;
public void setXBonusEJBAccessBean(XBonusEJBAccessBean xbonusAEJBccessBean);
public Integer getTotalBonusPoints() ;
public void setTotalBonusPoints(Integer totalBonusPoints);
public Integer getOldBonusPoints();
public void setOldBonusPoints(Integer oldBonusPoints);
}
package com.ibm.commerce.sample.commands;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.naming.NamingException;
import com.ibm.commerce.command.TaskCommandImpl;
import com.ibm.commerce.exception.ECException;
import com.ibm.commerce.user.objects.UserRegistryAccessBean;
import com.ibm.ejb.sample.XBonusEJBAccessBean;
public class MyNewTaskCmdImpl extends TaskCommandImpl implements MyNewTaskCmd {
String inputUserName;
Integer inputPoints;
String greetings;
UserRegistryAccessBean userRegistryAccessBean;
String foundUserId;
XBonusEJBAccessBean xbonusEJBAccessBean;
Integer totalBonusPoints;
Integer oldBonusPoints;
public XBonusEJBAccessBean getXBonusEJBAccessBean() {
return xbonusEJBAccessBean;
}
public void setXBonusEJBAccessBean(XBonusEJBAccessBean xbonusEJBAccessBean) {
this.xbonusEJBAccessBean = xbonusEJBAccessBean;
}
public Integer getTotalBonusPoints() {
return totalBonusPoints;
}
public void setTotalBonusPoints(Integer totalBonusPoints) {
this.totalBonusPoints = totalBonusPoints;
}
public Integer getOldBonusPoints() {
return oldBonusPoints;
}
public void setOldBonusPoints(Integer oldBonusPoints) {
this.oldBonusPoints = oldBonusPoints;
}
public UserRegistryAccessBean getUserRegistryAccessBean() {
return userRegistryAccessBean;
}
public void setUserRegistryAccessBean(
UserRegistryAccessBean userRegistryAccessBean) {
this.userRegistryAccessBean = userRegistryAccessBean;
}
public String getFoundUserId() {
return foundUserId;
}
public void setFoundUserId(String foundUserId) {
this.foundUserId = foundUserId;
}
public String getInputUserName() {
return inputUserName;
}
public void setInputUserName(String inputUserName) {
this.inputUserName = inputUserName;
}
public Integer getInputPoints() {
return inputPoints;
}
public void setInputPoints(Integer inputPoints) {
this.inputPoints = inputPoints;
}
public String getGreetings() {
return greetings;
}
public void setGreetings(String greetings) {
this.greetings = greetings;
}
@Override
public void performExecute() throws ECException {
// TODO Auto-generated method stub
super.performExecute();
setGreetings("Hello!!!" + getInputUserName());
int newBP = oldBonusPoints.intValue() + getInputPoints().intValue();
totalBonusPoints = new Integer(newBP);
xbonusEJBAccessBean.setBonusPoint(totalBonusPoints);
try {
xbonusEJBAccessBean.commitCopyHelper();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void validateParameters() throws ECException {
// TODO Auto-generated method stub
super.validateParameters();
if (userRegistryAccessBean != null) {
try {
setFoundUserId(userRegistryAccessBean.findByUserLogonId(
getInputUserName()).getUserId());
} catch (Exception e) {
// TODO: handle exception
}
} else {
try {
userRegistryAccessBean = new UserRegistryAccessBean();
userRegistryAccessBean = userRegistryAccessBean
.findByUserLogonId(getInputUserName());
setFoundUserId(userRegistryAccessBean.getUserId());
} catch (Exception e) {
e.printStackTrace();
}
}
if (xbonusEJBAccessBean != null) {
try {
setOldBonusPoints(xbonusEJBAccessBean.getBonusPoint());
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FinderException e) {
try {
xbonusEJBAccessBean = new XBonusEJBAccessBean(new Long(
getFoundUserId()));
xbonusEJBAccessBean.setBonusPoint(new Integer(0));
oldBonusPoints = new Integer(0);
} catch (Exception e2) {
// TODO: handle exception
}
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
try {
xbonusEJBAccessBean = new XBonusEJBAccessBean(new Long(
getFoundUserId()));
xbonusEJBAccessBean.setBonusPoint(new Integer(0));
oldBonusPoints = new Integer(0);
} catch (Exception e2) {
// TODO: handle exception
}
}
}
}
No comments:
Post a Comment