001: package multibase.business;
002:
003: import multibase.data.employee.*;
004: import multibase.data.employee.programer.*;
005:
006: import multibase.spec.*;
007:
008: public class MyDataManagerImpl implements MyDataManager {
009:
010: public void loadPr() {
011: String[][] programers = {
012: { "Scott", "Tiger", "advance", "DODS" },
013: { "Urchin", "Spinnes", "novice", "DODS" },
014: { "Jhon", "Erp", "advance", "Enhydra" },
015: { "Jim", "Earth", "advance", "Enhydra" } };
016: for (int i = 0; i < programers.length; i++) {
017: try {
018: ProgramerDO newP = ProgramerDO
019: .createVirgin("programer");
020: newP.setFirstName(programers[i][0]);
021: newP.setLastName(programers[i][1]);
022: newP.setExpirience(programers[i][2]);
023: newP.setProject(programers[i][3]);
024: newP.save();
025:
026: } catch (Exception e) {
027: }
028: }
029: }
030:
031: public void loadEm() {
032: String[][] employees = {
033: { "Bily", "Kid", "manager", "finance" },
034: { "Jerry", "Sttock", "manager", "consulting" },
035: { "Elly", "Beluchi", "director", "masterhood" },
036: { "Nattaly", "Sky", "seller", "marketing" } };
037: for (int i = 0; i < employees.length; i++) {
038: try {
039: EmployeeDO newE = EmployeeDO.createVirgin("employee");
040: newE.setFirstName(employees[i][0]);
041: newE.setLastName(employees[i][1]);
042: newE.setOccupation(employees[i][2]);
043: newE.setDepartment(employees[i][3]);
044: newE.save();
045:
046: } catch (Exception e) {
047: }
048: }
049: }
050:
051: public void transferPr() {
052: try {
053: ProgramerDO[] programers;
054: ProgramerQuery pQuery = new ProgramerQuery("programer");
055: programers = pQuery.getDOArray();
056: for (int i = 0; i < programers.length; i++) {
057: EmployeeDO newEmployee = EmployeeDO
058: .createVirgin("employee");
059: newEmployee.setFirstName(programers[i].getFirstName());
060: newEmployee.setLastName(programers[i].getLastName());
061: newEmployee.setOccupation("programer");
062: newEmployee.setDepartment("IT");
063: newEmployee.save();
064: }
065: } catch (Exception e) {
066: System.out.println(e.getMessage());
067:
068: }
069:
070: }
071:
072: public void deleteTr() {
073: try {
074: EmployeeDO[] emArray;
075: EmployeeQuery eQuery = new EmployeeQuery("employee");
076: eQuery.setQueryOccupation("programer");
077: emArray = eQuery.getDOArray();
078: for (int i = 0; i < emArray.length; i++) {
079: emArray[i].delete();
080: }
081: } catch (Exception e) {
082: System.out.println(e.getMessage());
083:
084: }
085: }
086:
087: public void deleteAll() {
088: try {
089: ProgramerDO[] pArray;
090: ProgramerQuery pQuery = new ProgramerQuery("programer");
091: pArray = pQuery.getDOArray();
092: for (int i = 0; i < pArray.length; i++) {
093: pArray[i].delete();
094: }
095:
096: EmployeeDO[] eArray;
097: EmployeeQuery eQuery = new EmployeeQuery("employee");
098: eArray = eQuery.getDOArray();
099: for (int i = 0; i < eArray.length; i++) {
100: eArray[i].delete();
101: }
102: } catch (Exception e) {
103: System.out.println(e.getMessage());
104:
105: }
106: }
107:
108: public String[][] getProgramers() {
109: String[][] result = null;
110: try {
111: ProgramerDO[] pArray;
112: ProgramerQuery pQuery = new ProgramerQuery("programer");
113: pArray = pQuery.getDOArray();
114: result = new String[pArray.length][4];
115: for (int i = 0; i < pArray.length; i++) {
116: result[i][0] = pArray[i].getFirstName();
117: result[i][1] = pArray[i].getLastName();
118: result[i][2] = pArray[i].getExpirience();
119: result[i][3] = pArray[i].getProject();
120: }
121: } catch (Exception e) {
122: System.out.println(e.getMessage());
123: }
124: return result;
125: }
126:
127: public String[][] getEmployees() {
128: String[][] result = null;
129: try {
130: EmployeeDO[] eArray;
131: EmployeeQuery eQuery = new EmployeeQuery("employee");
132: eArray = eQuery.getDOArray();
133: result = new String[eArray.length][4];
134: for (int i = 0; i < eArray.length; i++) {
135: result[i][0] = eArray[i].getFirstName();
136: result[i][1] = eArray[i].getLastName();
137: result[i][2] = eArray[i].getOccupation();
138: result[i][3] = eArray[i].getDepartment();
139: }
140: } catch (Exception e) {
141: System.out.println(e.getMessage());
142: }
143: return result;
144: }
145:
146: }
|