📄 conceptcontroller.java
字号:
/* */package org.impact.stars.control.ejb;import java.rmi.RemoteException;import javax.naming.InitialContext;import javax.naming.NamingException;import javax.ejb.CreateException;import javax.ejb.DuplicateKeyException;import javax.ejb.FinderException;import javax.ejb.RemoveException;import javax.ejb.EJBException;import java.util.*;import org.impact.stars.util.Debug;import org.impact.stars.util.JNDINames;import org.impact.stars.util.EJBUtil;import org.impact.stars.util.EJBKeys;import org.impact.stars.conceptmd.concept.ejb.ConceptLocal;import org.impact.stars.conceptmd.concept.ejb.ConceptLocalHome;import org.impact.stars.organizationmd.profilemgr.ejb.ProfileMgrLocal;import org.impact.stars.organizationmd.profilemgr.ejb.ProfileMgrLocalHome;import org.impact.stars.control.event.ConceptEvent;import org.impact.stars.control.event.StarsEvent;import org.impact.stars.control.exceptions.StarsEventException;import org.impact.stars.conceptmd.concept.exceptions.ConceptAppException;import org.impact.stars.control.exceptions.StarsAppException;/*import org.impact.stars.control.exceptions.DuplicateAccountException;*/public class ConceptController extends StateControllerSupport { public void perform(StarsEvent event) throws StarsEventException { ConceptEvent ce = (ConceptEvent)event; switch (ce.getActionType()) { case ConceptEvent.CREATE_CONCEPT_DATA: { Debug.println("ConceptController (ejb): CREATE_CONCEPT event"); try { ConceptLocalHome home = EJBUtil.getConceptLocalHome(); ConceptLocal cpt = home.create(ce.getCstrID(), ce.getConceptID(), ce.getName(), ce.getParentID(), ce.getType(), ce.getPstakeholder(), ce.getShared(), ce.getProposetime(), ce.getDefinition(), ce.getDescription()); Debug.println("ConceptController: created concept concept for " + ce.getConceptID()); } catch (CreateException cre) { throw new StarsAppException("Unable to create a new concept for " + ce.getConceptID() + " at this time"); } catch (javax.naming.NamingException nme) { throw new EJBException("Irrecoverable error creating concept: " + ce); } } break; case ConceptEvent.UPDATE_CONCEPT_DATA: { Debug.println("ConceptController (ejb): UPDATE_CONCEPT_DATA event"); try { Debug.println("ConceptController (ejb): updating concept concept for " + ce.getConceptID()); ConceptLocalHome home = EJBUtil.getConceptLocalHome(); ConceptLocal cpt = home.findByPrimaryKey(ce.getConceptID()); cpt.updateConcept(ce.getDefinition(), ce.getDescription(), ce.getName(), ce.getParentID(), ce.getProposetime(), ce.getPstakeholder(), ce.getShared(), ce.getType()); } catch (javax.ejb.FinderException fde) { throw new StarsAppException("Unable to find an concept/profile with concept id : " + ce.getConceptID()); } catch (javax.ejb.NoSuchEntityException nee) { throw new StarsAppException("Unable to find an concept/profile with concept id : " + ce.getConceptID()); } catch (javax.naming.NamingException nme) { Debug.println("ConceptController naming exception: " + nme); throw new EJBException("Irrecoverable error while updating concept : " + nme); } } break; case ConceptEvent.DELETE_CONCEPT: { Debug.println("ConceptController (ejb): DELETE_CONCEPT event"); try { Debug.println("ConceptController (ejb): deleting concept concept for " + ce.getConceptID()); ConceptLocalHome home = EJBUtil.getConceptLocalHome(); ConceptLocal cpt = home.findByPrimaryKey(ce.getConceptID()); removeAllChild(cpt, home); }catch (javax.ejb.FinderException fe) { throw new StarsAppException("Unable to find an concept/profile with concept id : " + ce.getConceptID()); } catch (javax.naming.NamingException nme) { Debug.println("ConceptController naming exception: " + nme); throw new EJBException("Irrecoverable error while updating concept : " + nme); } } break; default: Debug.print("ConcpetController: no action performed"); break; } } //used by delete to remove a branch in the tree private void removeAllChild(ConceptLocal concept, ConceptLocalHome home) throws StarsAppException { try{ Collection cptchild = home.findChildren(concept.getConceptID()); java.util.Iterator cptit = cptchild.iterator(); while(cptit.hasNext()) { ConceptLocal child = (ConceptLocal)cptit.next(); removeAllChild(child, home); } concept.remove(); }catch (javax.ejb.FinderException fe) { throw new StarsAppException("Problem to find an concept/profile with parent id : " + concept.getConceptID()); } catch (javax.ejb.RemoveException rme) { throw new StarsAppException("Unable to remove an concept/profile with concept id : " + concept.getConceptID()); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -