package com.westdata.xro.xrogwt.server; import com.westdata.xro.xrogwt.client.ProjectValidatorCF; import com.westdata.architecture.entity.EntityException; import com.westdata.architecture.entity.EntityUtility; import com.westdata.architecture.entity.conversion.IntegerConverter; import com.westdata.architecture.gwtapp.client.ControllerException; import com.westdata.architecture.gwtapp.client.TransferMap; import com.westdata.architecture.gwtapp.server.BindingException; import com.westdata.architecture.gwtapp.server.MetaBeanBinding; import com.westdata.architecture.gwtapp.server.ServerControllerImpl; import com.westdata.architecture.gwtapp.server.block.ModelBlockMany; import com.westdata.architecture.gwtapp.server.block.ModelBlockOne; import com.westdata.architecture.gwtcrud.server.StandardBlockModel; import com.westdata.architecture.gwtapp.client.block.BlockConfig; import com.westdata.architecture.gwtapp.client.block.BlockConfigField; import com.westdata.architecture.gwtapp.server.block.Block; import com.westdata.architecture.restwsclient.RestClientException; import com.westdata.xro.domain.wsclient.ProjectCRUDClient; import com.westdata.xro.domain.wsclient.SystemOptionsCRUDClient; import com.westdata.xro.domain.wsclient.XROProjectClient; import com.westdata.xro.domain.wsclient.XROSessionClient; import com.westdata.xro.entities.Authorization; import com.westdata.xro.entities.Project; import com.westdata.xro.entities.SystemOptions; import com.westdata.xro.xrogwt.client.ProjectMaintenancekModelConstants; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Collections; import java.util.Comparator; /** * The CRUD master maintenance style of block model, using the standard actions * * @author n1007016 */ public class ProjectMaintenanceModel extends StandardBlockModel implements ProjectMaintenancekModelConstants { private Unbound unbound; private Project current; private Project project; private Project task; private Project example; private List prospects; private String appname; private List projects = new ArrayList(); int mainWbsLen; int taskLen; int subtaskLen; private ModelBlockMany res; public ProjectMaintenanceModel() { } /** * * called when the controller creates a new model instance * * @param parameters * @throws com.westdata.xro.xrogwt.client.ControllerException */ public void create(TransferMap parameters) throws ControllerException { try { this.name = PROJECT_ENTITY + "CRUDModel"; this.appname = PROJECT_ENTITY + " Maintenance"; example = new Project(); Authorization a = new Authorization(); setUnbound(new Unbound(PROJECT_ENTITY)); setProspects(new ArrayList()); initBlocks(PROJECT_ENTITY); SystemOptions sysOpt = getSystemOptionsCRUDClient().find("Global Options"); Long mainWbsLenLong = sysOpt.getProjectMainWbsLength(); Long taskLenLong = sysOpt.getProjectTaskLength(); Long subtaskLenLong = sysOpt.getProjectSubtaskLength(); if(mainWbsLenLong == null || taskLenLong == null || subtaskLenLong == null) { throw new Exception("The global options have for Project Maintenance have not been set."); } mainWbsLen = mainWbsLenLong.intValue(); taskLen = taskLenLong.intValue(); subtaskLen = subtaskLenLong.intValue(); if(mainWbsLen == 0 || taskLen == 0 || subtaskLen == 0) { throw new Exception("The global options have for Project Maintenance have been set incorrectly."); } Block block = this.getBlock(NewProjectBlock); Map bindings = block.getBindings(); MetaBeanBinding metaBeanBinding = bindings.get("project"); metaBeanBinding.setValidator(new ProjectValidatorCF(mainWbsLen, "Main WBS")); block = this.getBlock(NewTaskBlock); bindings = block.getBindings(); metaBeanBinding = bindings.get("project"); metaBeanBinding.setValidator(new ProjectValidatorCF(taskLen, "Task")); block = this.getBlock(NewSubtaskBlock); bindings = block.getBindings(); metaBeanBinding = bindings.get("project"); metaBeanBinding.setValidator(new ProjectValidatorCF(subtaskLen, "Subtask")); update(parameters, null); } catch (Exception ex) { throw new ControllerException("model create failed", ex); } } protected void initBlocks(String entityName) throws ControllerException { add(new ModelBlockOne(CriteriaBlock, entityName, appname, "example", this)); res = new ModelBlockMany(ResultsBlock, ProjectPojo.class.getName(), appname, "projects", this); res.setReadOnly(true); add(res); ModelBlockOne mbo = new ModelBlockOne(ProjectReadOnlyBlock, entityName, appname, "project", this); mbo.setReadOnly(true); add(mbo); add(new ModelBlockOne(ProjectBlock, entityName, appname, "current", this)); add(new ModelBlockOne(NewProjectBlock, entityName, appname, "current", this)); mbo = new ModelBlockOne(TaskReadOnlyBlock, entityName, appname, "task", this); mbo.setReadOnly(true); add(mbo); add(new ModelBlockOne(TaskBlock, entityName, appname, "current", this)); add(new ModelBlockOne(NewTaskBlock, entityName, appname, "current", this)); add(new ModelBlockOne(SubtaskBlock, entityName, appname, "current", this)); add(new ModelBlockOne(NewSubtaskBlock, entityName, appname, "current", this)); buildBlocks(); } public void addBindings() throws ControllerException { this.getBindings().clear(); addBlockBindings(); try { addBinding(new MetaBeanBinding(FINDKEY_BINDING, "unbound.findName", false)); addBinding(new MetaBeanBinding(MATCHKEY_BINDING, "unbound.matchName", false)); addBinding(new MetaBeanBinding(ENTITY_BINDING, "unbound.entity", false)); addBinding(new MetaBeanBinding(VIEWMODE_BINDING, "unbound.viewmode", false)); addBinding(new MetaBeanBinding(CHILDREN_BINDING, "unbound.children", false, new IntegerConverter())); addBinding(new MetaBeanBinding(TYPE, "unbound.type", false, new IntegerConverter())); } catch(BindingException ex) { throw new ControllerException("Error adding bindings", ex); } this.getUnbound().setMatchName("%"); } /** * * make the selected item in the list the current one * * @throws com.westdata.xro.xrogwt.client.ControllerException */ public void select(int increment) throws ControllerException { try { int sel = res.getSelectedIndex(); if (getProspects() != null && getProspects().size() > sel) { sel += increment; if (sel < 0) { sel = getProspects().size() - 1; } else if (sel >= getProspects().size()) { sel = 0; } current = getProspects().get(sel); res.setSelectedIndex(sel); } else { throw new ControllerException("index out of range"); } } catch (Exception ex) { throw new ControllerException("select failed", ex); } } /** * * ask the domain to create and intitialize a new ${entityname} instance * * @param parameters * @throws com.westdata.xro.xrogwt.client.ControllerException */ public void create() throws ControllerException { fire(PRE_CREATE_ACTION); try { current = getProjectCRUDClient().create(); } catch (RestClientException ex) { throw new ControllerException("create failed", ex); } fire(POST_CREATE_ACTION); } /** * * revert the current instance to saved state (or to non-existence) * * @throws com.westdata.xro.xrogwt.client.ControllerException */ public void revert() throws ControllerException { int sel = res.getSelectedIndex(); if(sel == -1) return; select(0); if (current != null) { if (current.getId() == null || current.getId().longValue() < 0) { if (getProspects() != null && this.getProspects().contains(current)) { this.getProspects().remove(current); } select(0); } else { // it already exists, we must re-fetch it int ixr = this.getProspects().indexOf(current); try { current = getProjectCRUDClient().find(current.getId()); } catch (RestClientException ex) { throw new ControllerException("read failed", ex); } getProspects().set(ixr, current); } setProjects(createProjectPojos()); } } /** * * read (find) the instance * * @throws com.westdata.xro.xrogwt.client.ControllerException */ public void read() throws ControllerException { fire(PRE_READ_ACTION); try { current = getProjectCRUDClient().find(unbound.getFindName()); } catch (RestClientException ex) { throw new ControllerException("read failed", ex); } fire(POST_READ_ACTION); } private String padString(String p, int len, String pad){ int l = p.length(); if(l < len) { StringBuffer sb = new StringBuffer(); for(int i=l; i < len; i++) { sb.append(pad); } p += sb.toString(); } return p; } /** * * save (commit) the current instance * * @throws com.westdata.xro.xrogwt.client.ControllerException */ public void save() throws ControllerException { fire(PRE_SAVE_ACTION); try{ int type = getUnbound().getType().intValue(); Project upCurrent = null; if(type == PROJECT_ADD || type == PROJECT_EDIT) { current.setProject(padString(current.getProject(), mainWbsLen, " ")); } else if(type == TASK_ADD || type == TASK_EDIT) { StringBuffer sb = new StringBuffer(); sb.append(padString(project.getProject(), mainWbsLen, " ")) .append(padString(current.getProject(), taskLen, " ")); current.setProject(sb.toString()); } else if(type == SUBTASK_ADD || type == SUBTASK_EDIT) { StringBuffer sb = new StringBuffer(); sb.append(padString(project.getProject(), mainWbsLen, " ")) .append(padString(task.getProject(), taskLen, " ")) .append(padString(current.getProject(), subtaskLen, " ")); current.setProject(sb.toString()); } if (current.getId() != null) { upCurrent = getDomain().updateProject(current); } else { upCurrent = getDomain().addProject(current); } int ix = -1; if (getProspects() != null) { ix = getProspects().indexOf(current); if (ix != -1) { getProspects().set(ix, upCurrent); } else { getProspects().add(upCurrent); } } // we have to keep our rowver up to date setProjects(createProjectPojos()); current = upCurrent; if (getProspects() != null) ix = getProspects().indexOf(current); if(ix != -1) res.setSelectedIndex(ix); if(type == PROJECT_EDIT || type == PROJECT_ADD) { project = current; } else if(type == TASK_EDIT || type == TASK_ADD) { task = new Project(); EntityUtility.copy(current, task); current = task; if(ix != -1) { task.setProject(projects.get(ix).getTask()); } } else if(type == SUBTASK_EDIT || type == SUBTASK_ADD) { Project temp = new Project(); EntityUtility.copy(current, temp); current = temp; if(ix != -1) { current.setProject(projects.get(ix).getSubtask()); } } } catch (RestClientException ex) { throw new ControllerException("update failed", ex); } catch (EntityException ex) { throw new ControllerException("update failed", ex); } fire(POST_SAVE_ACTION); } /** * * delete the current instance * * @throws com.westdata.xro.xrogwt.client.ControllerException */ public void delete() throws ControllerException { fire(PRE_DELETE_ACTION); try { int sel = res.getSelectedIndex(); if (getProspects() != null && getProspects().size() > sel) { if (sel < 0) { sel = getProspects().size() - 1; } else if (sel >= getProspects().size()) { sel = 0; } current = getProspects().get(sel); ProjectPojo pp = getProjects().get(sel); current.setProject(pp.getFullProject()); getDomain().deleteProject(current); search(); } else { throw new ControllerException("index out of range"); } } catch (Exception ex) { throw new ControllerException("delete failed", ex); } fire(POST_DELETE_ACTION); } /** * * search for matching instances * * @throws com.westdata.xro.xrogwt.client.ControllerException */ public void search() throws ControllerException { fire(PRE_SEARCH_ACTION); List results; try { results = getProjectCRUDClient().findByExample(example); } catch (RestClientException ex) { throw new ControllerException("search failed", ex); } if (results == null) { results = new ArrayList(); } setProspects(results); setProjects(createProjectPojos()); current = null; fire(POST_SEARCH_ACTION); } /** * * find matching instances by name * * @throws com.westdata.xro.xrogwt.client.ControllerException */ public void match() throws ControllerException { List results = null; try { results = getProjectCRUDClient().getLOVList(unbound.getMatchName()); } catch (RestClientException ex) { throw new ControllerException("getLOVList failed", ex); } if (results == null) { results = new ArrayList(); } setProspects(results); setProjects(createProjectPojos()); current = null; } public Unbound getUnbound() { return unbound; } public void setUnbound(Unbound unbound) { this.unbound = unbound; } public Project getCurrent() { return current; } public void setCurrent(Project val) { this.current = val; } public Project getExample() { return example; } public void setExample(Project val) { this.example = val; } public List getProspects() { return prospects; } public void setProspects(List prospects) { this.prospects = prospects; } public XROProjectClient getDomain() throws ControllerException { return (XROProjectClient) ServerControllerImpl.getServerController().getWebServiceClient("XROProject"); } public ProjectCRUDClient getProjectCRUDClient() throws ControllerException { return (ProjectCRUDClient) XROServerController.getXROServerController().getCRUDServiceClient("Project"); } public SystemOptionsCRUDClient getSystemOptionsCRUDClient() throws ControllerException { return (SystemOptionsCRUDClient) XROServerController.getXROServerController().getCRUDServiceClient("SystemOptions"); } public XROSessionClient getXROSessionClient() throws ControllerException { return (XROSessionClient) ServerControllerImpl.getServerController().getWebServiceClient("XROSession"); } @Override public BlockConfig getInitialBlockConfig(String blockName) { BlockConfig rv = null; if (blockName.equals(CriteriaBlock)) { rv = new BlockConfig(PROJECT_ENTITY, blockName, appname, new String[]{"PROJECT", "STATUS"}, new String[]{}); rv.setMaxFieldWidth(120); // in effect, shortens the name widget to tighten up this block } else if (blockName.equals(ResultsBlock)) { rv = new BlockConfig(ProjectPojo.class.getName(), blockName, appname, new String[]{"project", "task", "subtask", "sstatus", "description", "contract", "dpasRating"}, new String[]{"Main WBS", "Task", "Subtask", "Status", "Description", "Contract", "DPAS Rating"}); rv.setMaxFieldWidth(100); BlockConfigField bcf = rv.getBlockFieldConfig("description"); bcf.setSize(160); } else if (blockName.equals(ProjectReadOnlyBlock)) { rv = new BlockConfig(PROJECT_ENTITY, blockName, appname, new String[]{"PROJECT", "DESCRIPTION", "STATUS", "CONTRACT.CONTRACT", "CONTRACT.DPAS_RATING"}, new String[]{"Main WBS", "Description", "Status", "Contract", "DPAS Rating"}); rv.addColumnBreak(3); BlockConfigField bcf = rv.getBlockFieldConfig("DESCRIPTION"); bcf.setSize(150); bcf.setReadOnly(true); bcf = rv.getBlockFieldConfig("PROJECT"); bcf.setSize(mainWbsLen+taskLen+subtaskLen); bcf.setReadOnly(true); bcf = rv.getBlockFieldConfig("STATUS"); bcf.setReadOnly(true); bcf = rv.getBlockFieldConfig("CONTRACT.CONTRACT"); bcf.setReadOnly(true); bcf.setSize(50); bcf = rv.getBlockFieldConfig("CONTRACT.DPAS_RATING"); bcf.setReadOnly(true); bcf.setSize(50); } else if (blockName.equals(ProjectBlock)) { rv = new BlockConfig(PROJECT_ENTITY, blockName, appname, new String[]{"PROJECT", "DESCRIPTION", "STATUS", "CONTRACT", "CONTRACT.DPAS_RATING"}, new String[]{"Main WBS", "Description", "Status", "Contract", "DPAS Rating"}); rv.addColumnBreak(3); BlockConfigField bcf = rv.getBlockFieldConfig("DESCRIPTION"); bcf.setSize(150); bcf = rv.getBlockFieldConfig("PROJECT"); bcf.setReadOnly(true); bcf.setSize(mainWbsLen+taskLen+subtaskLen); bcf = rv.getBlockFieldConfig("STATUS"); bcf.setReadOnly(true); bcf = rv.getBlockFieldConfig("CONTRACT.DPAS_RATING"); bcf.setReadOnly(true); bcf.setSize(50); } else if (blockName.equals(NewProjectBlock)) { rv = new BlockConfig(PROJECT_ENTITY, blockName, appname, new String[]{"PROJECT", "DESCRIPTION", "STATUS", "CONTRACT"}, new String[]{"Main WBS", "Description", "Status", "Contract"}); rv.addColumnBreak(3); BlockConfigField bcf = rv.getBlockFieldConfig("DESCRIPTION"); bcf.setSize(150); bcf = rv.getBlockFieldConfig("PROJECT"); bcf.setSize(mainWbsLen+taskLen+subtaskLen); bcf = rv.getBlockFieldConfig("STATUS"); bcf.setReadOnly(true); } else if (blockName.equals(TaskReadOnlyBlock)) { rv = new BlockConfig(PROJECT_ENTITY, blockName, appname, new String[]{"PROJECT", "DESCRIPTION", "STATUS"}, new String[]{"Task", "Description", "Status"}); BlockConfigField bcf = rv.getBlockFieldConfig("DESCRIPTION"); bcf.setSize(150); bcf.setReadOnly(true); bcf = rv.getBlockFieldConfig("PROJECT"); bcf.setSize(taskLen+subtaskLen); bcf.setReadOnly(true); bcf = rv.getBlockFieldConfig("STATUS"); bcf.setReadOnly(true); } else if (blockName.equals(TaskBlock)) { rv = new BlockConfig(PROJECT_ENTITY, blockName, appname, new String[]{"PROJECT", "DESCRIPTION", "STATUS"}, new String[]{"Task", "Description", "Status"}); BlockConfigField bcf = rv.getBlockFieldConfig("DESCRIPTION"); bcf.setSize(150); bcf = rv.getBlockFieldConfig("PROJECT"); bcf.setReadOnly(true); bcf.setSize(taskLen+subtaskLen); bcf = rv.getBlockFieldConfig("STATUS"); bcf.setReadOnly(true); } else if (blockName.equals(NewTaskBlock)) { rv = new BlockConfig(PROJECT_ENTITY, blockName, appname, new String[]{"PROJECT", "DESCRIPTION", "STATUS"}, new String[]{"Task", "Description", "Status"}); BlockConfigField bcf = rv.getBlockFieldConfig("DESCRIPTION"); bcf.setSize(150); bcf = rv.getBlockFieldConfig("PROJECT"); bcf.setSize(taskLen+subtaskLen); bcf = rv.getBlockFieldConfig("STATUS"); bcf.setReadOnly(true); } else if (blockName.equals(SubtaskBlock)) { rv = new BlockConfig(PROJECT_ENTITY, blockName, appname, new String[]{"PROJECT", "DESCRIPTION", "STATUS"}, new String[]{"Subtask", "Description", "Status"}); BlockConfigField bcf = rv.getBlockFieldConfig("DESCRIPTION"); bcf.setSize(150); bcf = rv.getBlockFieldConfig("PROJECT"); bcf.setReadOnly(true); bcf.setSize(subtaskLen); bcf = rv.getBlockFieldConfig("STATUS"); bcf.setReadOnly(true); } else if (blockName.equals(NewSubtaskBlock)) { rv = new BlockConfig(PROJECT_ENTITY, blockName, appname, new String[]{"PROJECT", "DESCRIPTION", "STATUS"}, new String[]{"Subtask", "Description", "Status"}); BlockConfigField bcf = rv.getBlockFieldConfig("DESCRIPTION"); bcf.setSize(150); bcf = rv.getBlockFieldConfig("PROJECT"); bcf.setSize(subtaskLen); bcf = rv.getBlockFieldConfig("STATUS"); bcf.setReadOnly(true); } return rv; } /** * * override of the superclass method for additional methods * * @param method * @param parameters * @param viewname * @return * @throws com.westdata.xro.xrogwt.client.ControllerException */ @Override public TransferMap execute(String method, TransferMap parameters, String viewname) throws ControllerException { TransferMap ret = new TransferMap(); if (method.equals(openAction)) { determineBindings(parameters); update(parameters, viewname); // need to update() so the search view can pass parms to the edit view open(); ret = refresh(viewname, false); } else if (method.equals(closeAction)) { determineBindings(parameters); update(parameters, viewname); // need to update() so the search view can pass parms to the edit view close(); ret = refresh(viewname, false); } else if (method.equals(editAction)) { determineBindings(parameters); update(parameters, viewname); // need to update() so the search view can pass parms to the edit view edit(); ret = refresh(viewname, false); } else if (method.equals(addTaskAction)) { determineBindings(parameters); update(parameters, viewname); // need to update() so the search view can pass parms to the edit view addTask(); ret = refresh(viewname, false); } else if (method.equals(addSubtaskAction)) { determineBindings(parameters); update(parameters, viewname); // need to update() so the search view can pass parms to the edit view addSubtask(); ret = refresh(viewname, false); } else if (method.equals(addTaskOrSubtaskFromEditAction)) { determineBindings(parameters); update(parameters, viewname); // need to update() so the search view can pass parms to the edit view addTaskOrSubtaskFromEditAction(); ret = refresh(viewname, false); } else if (method.equals(CRUD_SAVE_AND_ADD_TASK_OR_SUBTASK)) { determineBindings(parameters); update(parameters, viewname); save(); addTaskOrSubtaskFromEditAction(); ret = refresh(viewname, false); } else if (method.equals(CRUD_REVERT_AND_ADD_TASK_OR_SUBTASK)) { determineBindings(parameters); update(parameters, viewname); revert(); addTaskOrSubtaskFromEditAction(); ret = refresh(viewname, false); } else if (method.equals(deleteAction)) { determineBindings(parameters); update(parameters, viewname); // need to update() so the search view can pass parms to the edit view delete(); ret = refresh(viewname, false); } else if (method.equals(SEARCH_METHOD)) { determineBindings(parameters); update(parameters, viewname); // need to update() so the search view can pass parms to the edit view search(); ret = refresh(viewname, false); } else { ret = super.execute(method, parameters, viewname); } return ret; } /** * @return the projects */ public List getProjects() { return projects; } /** * @param projects the projects to set */ public void setProjects(List projects) { this.projects = projects; } private void addSubtask() throws ControllerException { try { int sel = res.getSelectedIndex(); if (getProspects() != null && getProspects().size() > sel) { if (sel < 0) { sel = getProspects().size() - 1; } else if (sel >= getProspects().size()) { sel = 0; } project = null; task = null; ProjectPojo currentPP = getProjects().get(sel); current = getProjectCRUDClient().create(); Project p = new Project(); p.setProject(currentPP.getProject()); List l = getProjectCRUDClient().findByExample(p); if(l != null && l.size() > 0) project = l.get(0); p = new Project(); p.setProject(currentPP.getProject() + currentPP.getTask()); l = getProjectCRUDClient().findByExample(p); if(l != null && l.size() > 0) { task = l.get(0); task.setProject(task.getTask(mainWbsLen, taskLen)); } } else { throw new ControllerException("index out of range"); } } catch (Exception ex) { throw new ControllerException("addSubtask failed", ex); } } private void addTask() throws ControllerException { try { int sel = res.getSelectedIndex(); if (getProspects() != null && getProspects().size() > sel) { if (sel < 0) { sel = getProspects().size() - 1; } else if (sel >= getProspects().size()) { sel = 0; } project = null; ProjectPojo currentPP = getProjects().get(sel); current = getProjectCRUDClient().create(); Project p = new Project(); p.setProject(currentPP.getProject()); List l = getProjectCRUDClient().findByExample(p); if(l != null && l.size() > 0) project = l.get(0); } else { throw new ControllerException("index out of range"); } } catch (Exception ex) { throw new ControllerException("addTask failed", ex); } } private void addTaskOrSubtaskFromEditAction() throws ControllerException { try { int ix = -1; if (getProspects() != null) ix = getProspects().indexOf(current); if(ix > -1) { project = null; task = null; ProjectPojo currentPP = getProjects().get(ix); Project p = new Project(); p.setProject(currentPP.getProject()); List l = getProjectCRUDClient().findByExample(p); if(l != null && l.size() > 0) project = l.get(0); p = new Project(); p.setProject(currentPP.getProject() + currentPP.getTask()); l = getProjectCRUDClient().findByExample(p); if(l != null && l.size() > 0) { task = l.get(0); task.setProject(task.getTask(mainWbsLen, taskLen)); } } current = getProjectCRUDClient().create(); } catch (Exception ex) { throw new ControllerException("addTaskOrSubtaskFromEditAction failed", ex); } } private void close() throws ControllerException { try { int sel = res.getSelectedIndex(); if (getProspects() != null && getProspects().size() > sel) { if (sel < 0) { sel = getProspects().size() - 1; } else if (sel >= getProspects().size()) { sel = 0; } current = getProspects().get(sel); ProjectPojo pp = getProjects().get(sel); current.setProject(pp.getFullProject()); int child = getUnbound().getChildren().intValue(); boolean children = false; if(child == 1) children = true; getDomain().closeProject(current, children); search(); } else { throw new ControllerException("index out of range"); } } catch (Exception ex) { throw new ControllerException("close failed", ex); } } private void edit() throws ControllerException { try { int sel = res.getSelectedIndex(); if (getProspects() != null && getProspects().size() > sel) { if (sel < 0) { sel = getProspects().size() - 1; } else if (sel >= getProspects().size()) { sel = 0; } project = null; task = null; current = getProspects().get(sel); ProjectPojo currentPP = getProjects().get(sel); if(currentPP.isSubtask()) { current.setProject(currentPP.getSubtask()); Project p = new Project(); p.setProject(currentPP.getProject()); List l = getProjectCRUDClient().findByExample(p); if(l != null && l.size() > 0) project = l.get(0); p = new Project(); p.setProject(currentPP.getProject()+currentPP.getTask()); l = getProjectCRUDClient().findByExample(p); if(l != null && l.size() > 0) { task = l.get(0); task.setProject(task.getTask(mainWbsLen, taskLen)); } } else if(currentPP.isTask()) { current.setProject(currentPP.getTask()); Project p = new Project(); p.setProject(currentPP.getProject()); List l = getProjectCRUDClient().findByExample(p); if(l != null && l.size() > 0) project = l.get(0); } else if(currentPP.isProject()) { // project = current; } } else { throw new ControllerException("index out of range"); } } catch (Exception ex) { throw new ControllerException("edit failed", ex); } } private void open() throws ControllerException { try { int sel = res.getSelectedIndex(); if (getProspects() != null && getProspects().size() > sel) { if (sel < 0) { sel = getProspects().size() - 1; } else if (sel >= getProspects().size()) { sel = 0; } current = getProspects().get(sel); ProjectPojo pp = getProjects().get(sel); current.setProject(pp.getFullProject()); int child = getUnbound().getChildren().intValue(); boolean children = false; if(child == 1) children = true; getDomain().openProject(current, children); search(); } else { throw new ControllerException("index out of range"); } } catch (Exception ex) { throw new ControllerException("open failed", ex); } } private List createProjectPojos() { Collections.sort(prospects, new Comparator() { public int compare(Object obj1, Object obj2) { String p1 = ((Project)obj1).getProject(); if(p1 == null) p1 = new String(); String p2 = ((Project)obj2).getProject(); if(p2 == null) p2 = new String(); return p1.compareTo(p2); } }); List projectPojos = new ArrayList(); //use this kind of iteration to assure order. int len = prospects.size(); for(int i=0; i < len; i++) { projectPojos.add(transformProject(prospects.get(i))); } return projectPojos; } private ProjectPojo transformProject(Project p) { if(p == null) return null; ProjectPojo pp = new ProjectPojo(p); if(p.getContract() != null){ pp.setContract(p.getContract().getContract()); pp.setDpasRating(p.getContract().getDpasRating()); } pp.setDescription(p.getDescription()); pp.setProject(p.getMainWBS(mainWbsLen)); pp.setSstatus(p.getStatus().toString()); pp.setTask(p.getTask(mainWbsLen, taskLen)); pp.setSubtask(p.getSubtask(mainWbsLen, taskLen, subtaskLen)); pp.setFullProject(p.getProject()); return pp; } /** * @return the project */ public Project getProject() { return project; } /** * @param project the project to set */ public void setProject(Project project) { this.project = project; } /** * @return the task */ public Project getTask() { return task; } /** * @param task the task to set */ public void setTask(Project task) { this.task = task; } public class Unbound implements Serializable{ private String project = null; private String Name = null; public String getProject() {return project;} public void setProject(String value) {this.project = value;} public String getName() {return Name;} public void setName(String value) {this.Name = value;} public Unbound(String entityName) { this.entity = entityName; } private String findName = null; private String matchName = null; public void setFindName(String value) { this.findName = value; } public String getFindName() { return findName; } public void setMatchName(String value) { this.matchName = value; } public String getMatchName() { return matchName; } private String entity; public String getEntity() { return entity; } public void setEntity(String entity) { this.entity = entity; } private String viewmode = "view"; private Long children = 0L; private Long type = 0L; public String getViewmode() { return viewmode; } public void setViewmode(String viewmode) { this.viewmode = viewmode; } /** * @return the children */ public Long getChildren() { return children; } /** * @param children the children to set */ public void setChildren(Long children) { this.children = children; } /** * @return the type */ public Long getType() { return type; } /** * @param type the type to set */ public void setType(Long type) { this.type = type; } } } ----- Classpath: --------------------------------------------- bootPath: C:\Program Files\Java\jdk1.6.0_06\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_06\jre\classes;C:\Program Files\Java\jdk1.6.0_06\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.6.0_06\jre\lib\ext\sunpkcs11.jar classPath: C:\Documents and Settings\j1008349\.m2\repository\com\google\gwt\gwt-servlet\1.5.2\gwt-servlet-1.5.2.jar;C:\Documents and Settings\j1008349\.m2\repository\com\google\gwt\gwt-user\1.5.2\gwt-user-1.5.2.jar;C:\Documents and Settings\j1008349\.m2\repository\com\westdata\xro\entities\1.1.41\entities-1.1.41.jar;C:\Documents and Settings\j1008349\.m2\repository\com\westdata\architecture\entitycore\1.1.52\entitycore-1.1.52.jar;C:\Documents and Settings\j1008349\.m2\repository\xerces\xercesImpl\2.4.0\xercesImpl-2.4.0.jar;C:\Documents and Settings\j1008349\.m2\repository\com\westdata\architecture\restws\1.1.52\restws-1.1.52.jar;C:\Documents and Settings\j1008349\.m2\repository\com\westdata\architecture\ejbapp\1.1.52\ejbapp-1.1.52.jar;C:\Documents and Settings\j1008349\.m2\repository\com\westdata\architecture\restclient\1.1.52\restclient-1.1.52.jar;C:\Documents and Settings\j1008349\.m2\repository\org\apache\geronimo\specs\geronimo-ejb_3.0_spec\1.0.1\geronimo-ejb_3.0_spec-1.0.1.jar;C:\Documents and Settings\j1008349\.m2\repository\com\westdata\xro\xrorestclient\1.1.41\xrorestclient-1.1.41.jar;C:\Documents and Settings\j1008349\.m2\repository\com\westdata\mrogwtgui\gwtapp\1.1.8-SNAPSHOT\gwtapp-1.1.8-SNAPSHOT.jar;C:\Documents and Settings\j1008349\.m2\repository\com\extjs\gxt\gxt\1.2.3\gxt-1.2.3.jar;C:\Documents and Settings\j1008349\.m2\repository\com\westdata\mrogwtgui\gwtcrud\1.1.8-SNAPSHOT\gwtcrud-1.1.8-SNAPSHOT.jar;C:\Documents and Settings\j1008349\.m2\repository\javax\persistence\persistence-api\1.0\persistence-api-1.0.jar;C:\Documents and Settings\j1008349\.m2\repository\com\sun\appserv-rt\1.0\appserv-rt-1.0.jar;C:\Documents and Settings\j1008349\.m2\repository\com\sun\appserv-ext\1.0\appserv-ext-1.0.jar;C:\Documents and Settings\j1008349\.m2\repository\com\sun\appserv-deployment-client\1.0\appserv-deployment-client-1.0.jar sourcePath: C:\clean\mrogwtgui\xromodel\src\main\java;C:\clean\mrogwtgui\xromodel\src\main\scala;C:\clean\mrogwtgui\xromodel\src\main\groovy;C:\clean\mrogwtgui\xromodel\src\main\resources ----- Original exception --------------------------------------------- java.lang.OutOfMemoryError: Java heap space at sun.text.UCompactIntArray.initPlane(UCompactIntArray.java:142) at sun.text.UCompactIntArray.setElementAt(UCompactIntArray.java:55) at java.text.RBTableBuilder.addOrder(RBTableBuilder.java:324) at java.text.RBTableBuilder.build(RBTableBuilder.java:136) at java.text.RBCollationTables.(RBCollationTables.java:65) at java.text.RuleBasedCollator.(RuleBasedCollator.java:276) at java.text.Collator.getInstance(Collator.java:251) at com.sun.tools.javadoc.DocLocale.(DocLocale.java:99) at com.sun.tools.javadoc.DocEnv.(DocEnv.java:140) at org.netbeans.modules.java.source.JavadocEnv.(JavadocEnv.java:100) at org.netbeans.modules.java.source.JavadocEnv.(JavadocEnv.java:86) at org.netbeans.modules.java.source.JavadocEnv$1.make(JavadocEnv.java:91) at org.netbeans.modules.java.source.JavadocEnv$1.make(JavadocEnv.java:89) at com.sun.tools.javac.util.Context.get(Context.java:145) at com.sun.tools.javadoc.DocEnv.instance(DocEnv.java:60) at com.sun.tools.javadoc.JavadocEnter.(JavadocEnter.java:62) at org.netbeans.modules.java.source.parsing.ErrorHandlingJavadocEnter.(ErrorHandlingJavadocEnter.java:70) at org.netbeans.modules.java.source.parsing.ErrorHandlingJavadocEnter$1.make(ErrorHandlingJavadocEnter.java:64) at org.netbeans.modules.java.source.parsing.ErrorHandlingJavadocEnter$1.make(ErrorHandlingJavadocEnter.java:62) at com.sun.tools.javac.util.Context.get(Context.java:145) at com.sun.tools.javac.comp.Enter.instance(Enter.java:114) at com.sun.tools.javac.comp.MemberEnter.(MemberEnter.java:96) at com.sun.tools.javadoc.JavadocMemberEnter.(JavadocMemberEnter.java:60) at com.sun.tools.javadoc.JavadocMemberEnter$1.make(JavadocMemberEnter.java:52) at com.sun.tools.javadoc.JavadocMemberEnter$1.make(JavadocMemberEnter.java:51) at com.sun.tools.javac.util.Context.get(Context.java:145) at com.sun.tools.javac.comp.MemberEnter.instance(MemberEnter.java:87) at com.sun.tools.javac.comp.Attr.(Attr.java:102) at com.sun.tools.javac.comp.Attr.instance(Attr.java:90) at com.sun.tools.javac.comp.Annotate.(Annotate.java:66) at com.sun.tools.javac.comp.Annotate.instance(Annotate.java:50) at com.sun.tools.javac.jvm.ClassReader.(ClassReader.java:241)