1 7 8 package multibase.presentation; 9 10 import com.lutris.appserver.server.httpPresentation.HttpPresentation; 12 import com.lutris.appserver.server.httpPresentation.HttpPresentationComms; 13 import com.lutris.appserver.server.httpPresentation.HttpPresentationException; 14 import org.w3c.dom.html.*; 15 import org.w3c.dom.Node ; 16 17 import java.io.IOException ; 19 import java.util.Date ; 20 import java.text.DateFormat ; 21 22 import multibase.spec.*; 24 import org.w3c.dom.Node ; 25 26 public class MultibasePresentation implements HttpPresentation { 27 28 29 public void run(HttpPresentationComms comms) 30 throws HttpPresentationException, IOException { 31 32 MultibaseHTML multibase; 33 MyDataManager dataManager; 34 35 36 multibase = (MultibaseHTML)comms.xmlcFactory.create(MultibaseHTML.class); 37 38 dataManager = MyDataManagerFactory.getMyDataManager("multibase.business.MyDataManagerImpl"); 39 40 41 try{ 42 String event = comms.request.getParameter("AppActionRg"); 43 if (event!=null){ 44 if (event.equals("loadPr")) { 45 dataManager.loadPr(); 46 47 } else if (event.equals("loadEm")){ 48 dataManager.loadEm(); 49 50 } else if (event.equals("transferPr")){ 51 dataManager.transferPr(); 52 53 } else if (event.equals("deleteTr")){ 54 dataManager.deleteTr(); 55 56 } else if (event.equals("deleteAll")){ 57 dataManager.deleteAll(); 58 } 59 } 60 61 String [][] programerArray=dataManager.getProgramers(); 62 String [][] employeeArray=dataManager.getEmployees(); 63 64 65 HTMLTableRowElement prTemplateRow = multibase.getElementPrTemplateRow(); 66 HTMLElement pFirstNameCellTemplate = multibase.getElementPFirstName(); 67 HTMLElement pLastNameCellTemplate = multibase.getElementPLastName(); 68 HTMLElement expirienceCellTemplate = multibase.getElementExpirience(); 69 HTMLElement projectCellTemplate = multibase.getElementProject(); 70 Node prTable = prTemplateRow.getParentNode(); 71 72 73 74 prTemplateRow .removeAttribute("id"); 75 pFirstNameCellTemplate.removeAttribute("id"); 76 pLastNameCellTemplate.removeAttribute("id"); 77 expirienceCellTemplate.removeAttribute("id"); 78 projectCellTemplate.removeAttribute("id"); 79 80 81 82 if (programerArray!=null){ 83 for (int numDiscs = 0; numDiscs < programerArray.length; numDiscs++) { 84 multibase.setTextPFirstName(programerArray[numDiscs][0]); 85 multibase.setTextPLastName (programerArray[numDiscs][1]); 86 multibase.setTextExpirience (programerArray[numDiscs][2]); 87 multibase.setTextProject (programerArray[numDiscs][3]); 88 prTable.appendChild(prTemplateRow.cloneNode(true)); 89 } 90 } 91 92 93 94 HTMLTableRowElement emTemplateRow = multibase.getElementEmTemplateRow(); 95 HTMLElement eFirstNameCellTemplate = multibase.getElementEFirstName(); 96 HTMLElement eLastNameCellTemplate = multibase.getElementELastName(); 97 HTMLElement occupationCellTemplate = multibase.getElementOccupation(); 98 HTMLElement departmentCellTemplate = multibase.getElementDepartment(); 99 Node emTable = emTemplateRow.getParentNode(); 100 101 102 103 emTemplateRow .removeAttribute("id"); 104 eFirstNameCellTemplate.removeAttribute("id"); 105 eLastNameCellTemplate.removeAttribute("id"); 106 occupationCellTemplate.removeAttribute("id"); 107 departmentCellTemplate.removeAttribute("id"); 108 109 110 111 if (employeeArray!=null){ 112 for (int numDiscs = 0; numDiscs < employeeArray.length; numDiscs++) { 113 multibase.setTextEFirstName(employeeArray[numDiscs][0]); 114 multibase.setTextELastName (employeeArray[numDiscs][1]); 115 multibase.setTextOccupation(employeeArray[numDiscs][2]); 116 multibase.setTextDepartment(employeeArray[numDiscs][3]); 117 emTable.appendChild(emTemplateRow.cloneNode(true)); 118 } 119 } 120 121 122 prTemplateRow.getParentNode().removeChild(prTemplateRow); 123 emTemplateRow.getParentNode().removeChild(emTemplateRow); 124 125 129 }catch(NullPointerException e){ 130 multibase.setTextMessage("MultiDb default page"); 131 } 132 comms.response.writeDOM(multibase); 133 } 134 135 } 136 | Popular Tags |