private void jButton1ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: Department hom = new Department(); hom.setVisible(true); this.dispose(); } // GEN-LAST:event_jButton1ActionPerformed
private Department getDept1() { Department dept = new Department(); dept.setBranch("Salt Lake City"); dept.setBranchHead("Kent Lewin"); dept.setMaxEmployees(100); dept.setNetwork("1A"); return dept; }
private Department getDept2() { Department dept = new Department(); dept.setBranch("Layton"); dept.setBranchHead("Terry Poperszky"); dept.setMaxEmployees(20); dept.setNetwork("2B"); return dept; }
private Department getDept3() { Department dept = new Department(); dept.setBranch("West Valley"); dept.setBranchHead("Pat Kelley"); dept.setMaxEmployees(15); dept.setNetwork("3C"); return dept; }
/* * Returns a list of teachers from the coordinator department that can be * tutors of a student from the given execution degree */ public List<Teacher> getPossibleTutorsFromExecutionDegreeDepartments() { Collection<Department> departments = this.getDegree().getDepartmentsSet(); ArrayList<Teacher> possibleTeachers = new ArrayList<Teacher>(); for (Department department : departments) { possibleTeachers.addAll(department.getPossibleTutors()); } return possibleTeachers; }
@Override public LargeMailUser clone() { LargeMailUser copy; try { copy = ((LargeMailUser) super.clone()); } catch (CloneNotSupportedException _x) { throw new InternalError((_x.toString())); } copy.addressLine = new ArrayList<AddressLine>((getAddressLine().size())); for (AddressLine iter : addressLine) { copy.addressLine.add(iter.clone()); } copy.largeMailUserName = new ArrayList<LargeMailUser.LargeMailUserName>((getLargeMailUserName().size())); for (LargeMailUser.LargeMailUserName iter : largeMailUserName) { copy.largeMailUserName.add(iter.clone()); } copy.largeMailUserIdentifier = ((largeMailUserIdentifier == null) ? null : ((LargeMailUser.LargeMailUserIdentifier) largeMailUserIdentifier.clone())); copy.buildingName = new ArrayList<BuildingName>((getBuildingName().size())); for (BuildingName iter : buildingName) { copy.buildingName.add(iter.clone()); } copy.department = ((department == null) ? null : ((Department) department.clone())); copy.postBox = ((postBox == null) ? null : ((PostBox) postBox.clone())); copy.thoroughfare = ((thoroughfare == null) ? null : ((Thoroughfare) thoroughfare.clone())); copy.postalCode = ((postalCode == null) ? null : ((PostalCode) postalCode.clone())); copy.any = new ArrayList<Object>((getAny().size())); for (Object iter : any) { copy.any.add(iter); } return copy; }
@Test public void testEqualsObject() { assertTrue( "Test Address Order 1 and 2 should equal each other", TestDepartmentObject1.equals(TestDepartmentObject2)); assertFalse( "Test Address Order 1 and 3 should not equal each other - Id", TestDepartmentObject1.equals(TestDepartmentObject3)); assertFalse( "Test Address Order 1 and 4 should not equal each other - Name", TestDepartmentObject1.equals(TestDepartmentObject4)); assertFalse( "Test Address Order 1 and 5 should not equal each other - Chair", TestDepartmentObject1.equals(TestDepartmentObject5)); }
/*Update Department method was created for Update a record from Department, folowing DepartmentID*/ public static void updateDepartment(Department department) throws SQLException, ClassNotFoundException { Connection conn = EmpConnection.getConnection(); StringBuilder query = new StringBuilder(); query.append("use QLNS_JAVA2 UPDATE [dbo].[Departments] SET [DepartmentName] = ?"); query.append(" WHERE [DepartmentID] = ?"); PreparedStatement pStmt = conn.prepareStatement(query.toString()); pStmt.setString(1, department.getDepartmentName()); pStmt.setInt(2, department.getDepartmentID()); pStmt.executeUpdate(); EmpConnection.closePreparedStatement(pStmt); EmpConnection.closeConnection(conn); }
public static void main(String args[]) { Employee hrManager = new Employee( "1", "SpongeBob", "SquarePants", "HR Manager", new Date(System.currentTimeMillis())); Department hr = new Department(); hr.setManager(hrManager); hr.setName("Humane Resources"); try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("hr.ser"))) { out.writeObject(hr); System.out.println("Wrote \"" + hr.getName() + "\" to file"); } catch (IOException e) { System.err.println("Error writing object: " + e.getMessage()); } }
/** * Method to call when we want to apply (grant or deny) an agreement visa * * @param employee * @param visaStatus * @param comment * @return */ public Request applyAgreementVisa( Employee employee, RequestAgreementVisaStatus visaStatus, String comment) { if (!waitsForAnAgreementVisa()) { throw REQUEST_DOES_NOT_EXPECT_ANY_AGREEMENT_VISA.exception(); } if (userHasAlreadyAppliedAVisa(employee.getId())) { throw EMPLOYEE_HAS_ALREADY_APPLIED_A_VISA.exception(employee.getFullName()); } AgreementRuleVisaAud nextExpectedVisa = getNextExpectedAgreementVisa() .orElseThrow(() -> COULD_NOT_FIND_NEXT_EXPECTED_AGREEMENT_VISA.exception()); Department department = employee.getDepartment(); Seniority seniority = employee.getSeniority(); if (!nextExpectedVisa.canBeAppliedBy(department, seniority)) { throw VISA_TO_APPLY_DOESNT_MATCH_NEXT_EXPECTED_ONE.exception( department.getName(), seniority.getValue(), nextExpectedVisa.getDepartment().getName(), nextExpectedVisa.getSeniority().getValue()); } LocalDateTime now = LocalDateTime.now(); RequestAgreementVisa appliedVisa = RequestAgreementVisa.build( this, null, employee, visaStatus, nextAgreementVisaRank, comment, department, seniority, now); addAgreementVisa(appliedVisa); updateUser = employee.getUid(); updateDate = now; return this; }
@Override protected Void doInBackground(Void... arg0) { try { XmlResourceParser parser = getResources().getXml(R.xml.departments); int eventType = parser.getEventType(); while (eventType != XmlResourceParser.END_DOCUMENT) { if (eventType == XmlResourceParser.START_TAG && parser.getName().equalsIgnoreCase("department")) { Department d = new Department(); d.setName(parser.getAttributeValue(null, "name")); d.setUrl(parser.getAttributeValue(null, "url")); List<HoursForDayOfWeek> hoursOfOperation = new ArrayList<HoursForDayOfWeek>(); eventType = parser.next(); if (parser.getName().equalsIgnoreCase("hoursofoperation")) { eventType = parser.next(); for (int i = 1; i <= 7; i++) { HoursForDayOfWeek day = new HoursForDayOfWeek(); day.setDayOfWeek(parser.getAttributeIntValue(null, "dayOfWeek", 1)); day.setOpeningTime(parser.getAttributeIntValue(null, "openingTime", 0)); day.setClosingTime(parser.getAttributeIntValue(null, "closingTime", 0)); hoursOfOperation.add(day); eventType = parser.next(); eventType = parser.next(); } d.setHoursOfOperation(hoursOfOperation); } departments.add(d); } else { eventType = parser.next(); } } } catch (MalformedURLException e) { Log.e("GGC-CONNECT", "MalformedURL", e); } catch (XmlPullParserException e) { Log.e("GGC-CONNECT", "XmlPULLParser", e); } catch (IOException e) { Log.e("GGC-CONNECT", "IO", e); } return null; }
@Override public void dataBind() { tableComponent.setParentModel(department); tableComponent.setModel(department.getDivisions()); tableComponent.dataBind(); if (getModel() != null) tableComponent.setSelectedValue(getModel().getBean()); }
public void departTest() { Department department1 = depDAO.getDepartment(1); Department department2 = depDAO.getDepartment(2); Department department3 = depDAO.getDepartment(3); Worker worker1 = new Worker("jaku", 18); worker1.setWorkerPassword("111111"); worker1.setDepartment(department1); worker1.setWorkerLevel(1); Worker worker2 = new Worker("balen", 28); worker2.setWorkerPassword("111111"); worker2.setDepartment(department2); worker2.setWorkerLevel(2); Worker worker3 = new Worker("admin", 38); worker3.setWorkerPassword("111111"); worker3.setDepartment(department3); worker3.setWorkerLevel(3); department1.addWorker(worker1); department2.addWorker(worker2); department3.addWorker(worker3); depDAO.saveDepart(department1); depDAO.saveDepart(department2); depDAO.saveDepart(department3); }
public static void main(String[] args) { SessionFactory sf = HibernateUtil.getSessionFactory(); Session session = sf.openSession(); session.beginTransaction(); Department department = new Department(); department.setDepartmentName("Sales"); session.save(department); Employee emp1 = new Employee("Nina", "Mayers", "1212"); Employee emp2 = new Employee("Tony", "Almeida", "4343"); emp1.setDepartment(department); emp2.setDepartment(department); session.save(emp1); session.save(emp2); session.getTransaction().commit(); session.close(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = ((prime * result) + ((addressLine == null) ? 0 : addressLine.hashCode())); result = ((prime * result) + ((largeMailUserName == null) ? 0 : largeMailUserName.hashCode())); result = ((prime * result) + ((largeMailUserIdentifier == null) ? 0 : largeMailUserIdentifier.hashCode())); result = ((prime * result) + ((buildingName == null) ? 0 : buildingName.hashCode())); result = ((prime * result) + ((department == null) ? 0 : department.hashCode())); result = ((prime * result) + ((postBox == null) ? 0 : postBox.hashCode())); result = ((prime * result) + ((thoroughfare == null) ? 0 : thoroughfare.hashCode())); result = ((prime * result) + ((postalCode == null) ? 0 : postalCode.hashCode())); result = ((prime * result) + ((any == null) ? 0 : any.hashCode())); result = ((prime * result) + ((underscore == null) ? 0 : underscore.hashCode())); return result; }
public static int insertDepartment(Department department) throws ClassNotFoundException, SQLException { int result = 0; Connection conn = EmpConnection.getConnection(); StringBuilder query = new StringBuilder(); query.append("use QLNS_JAVA2 INSERT INTO [dbo].[Departments]( [DepartmentName] ) VALUES(?) "); PreparedStatement pStmt = conn.prepareStatement(query.toString()); pStmt.setString(1, department.getDepartmentName()); pStmt.executeUpdate(); // Get Max ID and Return/ pStmt = conn.prepareStatement("use QLNS_JAVA2 SELECT MAX(DepartmentID) AS MaxID FROM Departments"); ResultSet rs = pStmt.executeQuery(); rs.next(); result = rs.getInt("MaxID"); EmpConnection.closePreparedStatement(pStmt); EmpConnection.closeConnection(conn); return result; // de minh chi cho ban cho ma chay bi loi ne }
@Test public void departmentTest() throws Exception { Department dpNew = new Department(); em.getTransaction().begin(); dpNew.setName("Bob's Department"); dpNew.setLocation("Baltimore"); em.persist(dpNew); em.getTransaction().commit(); int newId = dpNew.getId(); // test earlier persist Department dpLoad1 = em.find(Department.class, newId); assertEquals(dpLoad1.getId(), newId); assertEquals("Insert didn't work", dpLoad1.getName(), "Bob's Department"); assertEquals("Insert didn't work", dpLoad1.getLocation(), "Baltimore"); // test update em.getTransaction().begin(); dpLoad1.setName("Phil's Department"); dpLoad1.setLocation("Philadelphia"); em.getTransaction().commit(); Department dpLoad2 = em.find(Department.class, newId); assertEquals(dpLoad2.getId(), newId); assertEquals("Update didn't work", dpLoad2.getName(), "Phil's Department"); assertEquals("Update didn't work", dpLoad2.getLocation(), "Philadelphia"); em.getTransaction().begin(); em.remove(dpLoad1); em.getTransaction().commit(); Department shouldBeNull = em.find(Department.class, newId); assertNull("Delete didn't work", shouldBeNull); }
public Double visit(Company o) { double total = 0; for (Department d : o.getDepts()) total += d.accept(this); return total; }
public Double visit(Department o) { double total = 0; total += o.getManager().accept(this); for (Subunit s : o.getSubunits()) total += s.accept(this); return total; }
void testModifyEmployee() { Department department1 = this.new Department(); Department department2 = this.new Department(); Employee employee1 = new Employee(); Employee employee2 = new Employee(); AssociationTests.assertCollection(department1.getEmployees()); AssociationTests.assertCollection(department2.getEmployees()); Assert.assertNull(employee1.getDepartment()); Assert.assertNull(employee2.getDepartment()); employee1.setDepartment(department1); AssociationTests.assertCollection(department1.getEmployees(), employee1); AssociationTests.assertCollection(department2.getEmployees()); Assert.assertEquals(department1, employee1.getDepartment()); Assert.assertNull(employee2.getDepartment()); employee2.setDepartment(department1); AssociationTests.assertCollection(department1.getEmployees(), employee1, employee2); AssociationTests.assertCollection(department2.getEmployees()); Assert.assertEquals(department1, employee1.getDepartment()); Assert.assertEquals(department1, employee2.getDepartment()); employee1.setDepartment(department2); AssociationTests.assertCollection(department1.getEmployees(), employee2); AssociationTests.assertCollection(department2.getEmployees(), employee1); Assert.assertEquals(department2, employee1.getDepartment()); Assert.assertEquals(department1, employee2.getDepartment()); employee2.setDepartment(department2); AssociationTests.assertCollection(department1.getEmployees()); AssociationTests.assertCollection(department2.getEmployees(), employee1, employee2); Assert.assertEquals(department2, employee1.getDepartment()); Assert.assertEquals(department2, employee2.getDepartment()); employee2.setDepartment(null); AssociationTests.assertCollection(department1.getEmployees()); AssociationTests.assertCollection(department2.getEmployees(), employee1); Assert.assertEquals(department2, employee1.getDepartment()); Assert.assertNull(employee2.getDepartment()); employee1.setDepartment(null); AssociationTests.assertCollection(department1.getEmployees()); AssociationTests.assertCollection(department2.getEmployees()); Assert.assertNull(employee1.getDepartment()); Assert.assertNull(employee2.getDepartment()); }
public static void main(String[] args) throws IOException, ParseException { Department dept = new Department("ComputerScience"); // The following commented out code will help you // create the objects that you need. // /******************************************************* // Create faculty objects Faculty frankMoore = new Faculty("Frank Moore", "472-5921", 43, 10000); Faculty samHoward = new Faculty("Sam Howard", "472-7222", 55, 9500); Faculty johnDoodle = new Faculty("John Doodle", "472-6190", 39, 8600); dept.addPerson(frankMoore); dept.addPerson(samHoward); dept.addPerson(johnDoodle); // Create student objects Student johnDoe = new Student("John Doe", "472-1121", 22, 4.0); Student maryJones = new Student("Mary Jones", "472-7322", 32, 3.80); Student leeJohnson = new Student("Lee Johnson", "472-6009", 19, 3.65); dept.addPerson(johnDoe); dept.addPerson(maryJones); dept.addPerson(leeJohnson); // Create staff objects Staff frankGore = new Staff("Frank Gore", "472-3321", 33, 4050); Staff adamDavis = new Staff("Adam Davis", "472-7552", 50, 5500); Staff davidHeck = new Staff("David Heck", "472-8890", 29, 3600); dept.addPerson(frankGore); dept.addPerson(adamDavis); dept.addPerson(davidHeck); // Create course objects Course cs201 = new Course("cs201", "programming", 4, johnDoodle); Course cs360 = new Course("cs360", "database", 3, samHoward); Course cs404 = new Course("cs404", "compiler", 4, johnDoodle); Course cs240 = new Course("cs240", "datastructure", 2, johnDoodle); Course cs301 = new Course("cs301", "Software engg", 3, samHoward); Course cs450 = new Course("cs450", "Advanced architecture", 5, frankMoore); frankMoore.addCourse(cs450); johnDoodle.addCourse(cs240); samHoward.addCourse(cs450); frankMoore.addCourse(cs450); // Create StaffStudent objects SimpleDateFormat format = new SimpleDateFormat("yyMMdd"); StaffStudent prabhat = new StaffStudent("Prabhat", "472-1121", 22, 4000.0, 4.0, format.parse("880711")); // Student maryJones = new Student("Mary Jones","472-7322",32,3.80); // Student leeJohnson = new Student("Lee Johnson","472-6009",19,3.65); dept.addPerson(prabhat); // dept.addPerson(maryJones); // dept.addPerson(leeJohnson); /** * ***************************************************** /* The above course objects will go * inside either a faculty object, or a student object. Not all of the course objects go into * the same object. * * <p>You would have code that looks something like : frankMoore.addCourse(cs450); * * <p>The addCourse method would have to be written in the faculty class. Something similar * would be done for students. */ /** ***************************************************** */ double totsalary = 0; while (true) { putText("Enter first letter of "); putText("getTotalSalary, showAllMembers, unitsPerFaculty or quit : "); int choice = getChar(); switch (choice) { case 'g': totsalary = dept.getTotalSalary(); putText("Total sum of all salaries is:"); System.out.printf("$%,.2f \n", totsalary); // putText(String.valueOf(totsalary)+"\n"); break; case 's': dept.showAllMembers(); break; case 'u': dept.unitsPerFaculty(); break; case 'a': dept.displayStudent("Frank Moore"); break; case 'q': return; default: putText("Invalid entry\n"); } // end switch } // end while } // end main()
@Override public void build( JsonObjectBuilder pBuilder, Examiner pReadOnly, UriInfo pUriInfo, LocalCache pLocalCache) { if (pReadOnly.getId() != null) { pBuilder.add("id", pReadOnly.getId()); } Course course = (Course) pLocalCache.cache(() -> pReadOnly.getCourse(), pReadOnly.getCourseId(), Course.class); pBuilder.add("courseId", course.getId()); pBuilder.add("courseNo", course.getNo()); pBuilder.add("courseTitle", course.getTitle()); pBuilder.add("courseCrHr", course.getCrHr()); pBuilder.add("year", course.getYear()); pBuilder.add("semester", course.getSemester()); pBuilder.add("syllabusId", course.getSyllabusId()); if (!StringUtils.isEmpty(pReadOnly.getPreparerId())) { Teacher teacher = (Teacher) pLocalCache.cache( () -> pReadOnly.getPreparer(), pReadOnly.getPreparerId(), Teacher.class); pBuilder.add("preparerId", teacher.getId()); pBuilder.add("preparerName", teacher.getName()); } if (!StringUtils.isEmpty(pReadOnly.getScrutinizerId())) { Teacher teacher = (Teacher) pLocalCache.cache( () -> pReadOnly.getScrutinizer(), pReadOnly.getScrutinizerId(), Teacher.class); pBuilder.add("scrutinizerId", teacher.getId()); pBuilder.add("scrutinizerName", teacher.getName()); } Department department = (Department) pLocalCache.cache( () -> course.getOfferedBy(), course.getOfferedDepartmentId(), Department.class); pBuilder.add("courseOfferedByDepartmentId", department.getId()); pBuilder.add("courseOfferedByDepartmentName", department.getShortName()); Syllabus syllabus = (Syllabus) pLocalCache.cache(() -> course.getSyllabus(), course.getSyllabusId(), Syllabus.class); Program program = (Program) pLocalCache.cache(() -> syllabus.getProgram(), syllabus.getProgramId(), Program.class); Department offeredToDepartment = (Department) pLocalCache.cache( () -> program.getDepartment(), program.getDepartmentId(), Department.class); pBuilder.add("courseOfferedToDepartmentId", offeredToDepartment.getId()); pBuilder.add("courseOfferedToDepartmentName", offeredToDepartment.getShortName()); }
public void addDepartment(Department department) { getDepartments().add(department); department.setCompany(this); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if ((obj instanceof LargeMailUser) == false) { return false; } LargeMailUser other = ((LargeMailUser) obj); if (addressLine == null) { if (other.addressLine != null) { return false; } } else { if (addressLine.equals(other.addressLine) == false) { return false; } } if (largeMailUserName == null) { if (other.largeMailUserName != null) { return false; } } else { if (largeMailUserName.equals(other.largeMailUserName) == false) { return false; } } if (largeMailUserIdentifier == null) { if (other.largeMailUserIdentifier != null) { return false; } } else { if (largeMailUserIdentifier.equals(other.largeMailUserIdentifier) == false) { return false; } } if (buildingName == null) { if (other.buildingName != null) { return false; } } else { if (buildingName.equals(other.buildingName) == false) { return false; } } if (department == null) { if (other.department != null) { return false; } } else { if (department.equals(other.department) == false) { return false; } } if (postBox == null) { if (other.postBox != null) { return false; } } else { if (postBox.equals(other.postBox) == false) { return false; } } if (thoroughfare == null) { if (other.thoroughfare != null) { return false; } } else { if (thoroughfare.equals(other.thoroughfare) == false) { return false; } } if (postalCode == null) { if (other.postalCode != null) { return false; } } else { if (postalCode.equals(other.postalCode) == false) { return false; } } if (any == null) { if (other.any != null) { return false; } } else { if (any.equals(other.any) == false) { return false; } } if (underscore == null) { if (other.underscore != null) { return false; } } else { if (underscore.equals(other.underscore) == false) { return false; } } return true; }
/* * Add a new record to the Organization table, * creates an admin account when SA creates a new consulting company * @param OrganizationCode (based on Company Name) * @param OrganizationName (based on Company Description) * @param FKCompanyID * @param NameSequence * @param PKUser * @param nomRater * @throws SQLException * @throws Exception * @author: Mark Oei * @since v.1.3.12.63 09 Mar 2010 */ public boolean addOrganisationByCons( String OrganizationCode, String OrganizationName, int FKCompanyID, int NameSequence, int PKUser, String nomRater) throws SQLException, Exception { Connection con = null; Statement st = null; boolean bIsAdded = false; String sql = "INSERT INTO tblOrganization (OrganizationCode, OrganizationName, FKCompanyID, NameSequence, NominationModule)"; sql = sql + " VALUES ('" + OrganizationCode + "', '" + OrganizationName + "', " + FKCompanyID + ", " + NameSequence + ", '" + Boolean.parseBoolean(nomRater) + "')"; try { con = ConnectionBean.getConnection(); st = con.createStatement(); int iSuccess = st.executeUpdate(sql); System.out.println(iSuccess); if (iSuccess != 0) bIsAdded = true; } catch (Exception E) { System.err.println("Organization.java - AddRecord - " + E); } finally { ConnectionBean.closeStmt(st); // Close statement ConnectionBean.close(con); // Close connection } System.out.println("1. Add Organization"); // add default under the organization. String defaultName = "NA"; int FKOrganization = checkOrgExist(OrganizationCode, OrganizationName, FKCompanyID); // Change to disable print statement. Used for debugging only // Mark Oei 19 Mar 2010 // System.out.println("testing " + FKOrganization); System.out.println("2. Check Organization Exist"); if (FKOrganization != 0) { // Add Division div.addRecord(defaultName, FKOrganization, PKUser); System.out.println("3. Add Division"); // Add Department dept.addRecord(defaultName, FKOrganization, PKUser); System.out.println("4. Add Department"); // Add Group G.addRecord(defaultName, FKOrganization, PKUser); System.out.println("5. Add Group"); // Check whether exists int FKDivision = div.checkDivExist(defaultName, FKOrganization); int FKDepartment = dept.checkDeptExist(defaultName, FKOrganization); int FKGroup = G.checkGroupExist(defaultName, FKOrganization); // Create links dept.linkDepartment(FKDivision, FKDepartment); G.linkGroup(FKDepartment, FKGroup); // Establish new admin account and password Date timeStamp = new java.util.Date(); SimpleDateFormat dFormat = new SimpleDateFormat("ddMMyyHHmmss"); String temp = dFormat.format(timeStamp); String loginName = OrganizationCode + "admin"; String password = OrganizationCode + temp; int userType = 6; // Insert record into database U.addRecord( FKDepartment, FKDivision, userType, "Admin", "Admin", loginName, "NA", "NA", FKGroup, password, 1, FKCompanyID, FKOrganization, "NA", PKUser); System.out.println("6. Add User"); int userExist = U.checkUserExist( FKDepartment, FKDivision, userType, "Admin", "Admin", loginName, "NA", "NA", FKGroup, password, 1, FKCompanyID, FKOrganization); System.out.println( "FKDivision = " + FKDivision + ", FKDepartment = " + FKDepartment + ", FKGroup = " + FKGroup + " and User Exist = " + userExist); if (userExist != 0) { try { U.insertRelation(userExist, userExist, 0); } catch (SQLException SE) { System.out.println(SE.getMessage()); } // Send email notification String content = template.ForgotPass_temp(loginName, password); String email = "*****@*****.**"; // Edited By Roger 13 June 2008 Email.sendMail( server.getAdminEmail(), email, "New Admin Assignment for " + OrganizationName, content, FKOrganization); } System.out.println("8. Add User Relation"); } sDetail = detail.getUserDetail(PKUser); ev.addRecord("Insert", itemName, OrganizationName, sDetail[2], sDetail[11], sDetail[10]); return bIsAdded; } // End Method for addOrganisationByCons
public Department createDepartment(String name, String sn, Date date) { Department result = new Department(name, sn); result.setCreateDate(date); result.save(); return result; }
public static void main(String[] args) { ApplicationContext ac = new ClassPathXmlApplicationContext("com/tyy/spring4/tag/util/beans.xml"); Employee e1 = ac.getBean("employee1", Employee.class); Employee e2 = ac.getBean("employee2", Employee.class); Department depart = (Department) ac.getBean("department"); System.out.println(e1); System.out.println(e2); System.out.println("Department: " + depart.getId() + " " + depart.getName()); System.out.println("\nArray:"); for (Employee e : depart.getEmployeeArray()) { System.out.println(e); } System.out.println("\nList:"); System.out.println(depart.getEmployeeList().getClass()); for (Employee e : depart.getEmployeeList()) { System.out.println(e); } // Set元素具有唯一性,多次添加不会报错,但无效(本例中应该重写Employee的equals方法和hashCode方法) System.out.println("\nSet:"); System.out.println(depart.getEmployeeSet().getClass()); for (Employee e : depart.getEmployeeSet()) { System.out.println(e); } System.out.println("\nMap:"); System.out.println(depart.getEmployeeMap().getClass()); for (Entry<String, Employee> entry : depart.getEmployeeMap().entrySet()) { System.out.println("key: " + entry.getKey() + "; value: " + entry.getValue()); } System.out.println("\nProperties:"); System.out.println(depart.getEmployeeProperties().getClass()); Properties prop = depart.getEmployeeProperties(); Enumeration<String> propNames = (Enumeration<String>) prop.propertyNames(); while (propNames.hasMoreElements()) { String propName = propNames.nextElement(); System.out.println("Property -> key: " + propName + ", value: " + prop.getProperty(propName)); } }
void testModifyDepartment() { Department department1 = this.new Department(); Department department2 = this.new Department(); Employee employee1 = new Employee(); Employee employee2 = new Employee(); AssociationTests.assertCollection(department1.getEmployees()); AssociationTests.assertCollection(department2.getEmployees()); Assert.assertNull(employee1.getDepartment()); Assert.assertNull(employee2.getDepartment()); department1.getEmployees().add(employee1); AssociationTests.assertCollection(department1.getEmployees(), employee1); AssociationTests.assertCollection(department2.getEmployees()); Assert.assertEquals(department1, employee1.getDepartment()); Assert.assertNull(employee2.getDepartment()); department1.getEmployees().add(employee2); AssociationTests.assertCollection(department1.getEmployees(), employee1, employee2); AssociationTests.assertCollection(department2.getEmployees()); Assert.assertEquals(department1, employee1.getDepartment()); Assert.assertEquals(department1, employee2.getDepartment()); department2.getEmployees().add(employee1); AssociationTests.assertCollection(department1.getEmployees(), employee2); AssociationTests.assertCollection(department2.getEmployees(), employee1); Assert.assertEquals(department2, employee1.getDepartment()); Assert.assertEquals(department1, employee2.getDepartment()); department2.getEmployees().add(employee2); AssociationTests.assertCollection(department1.getEmployees()); AssociationTests.assertCollection(department2.getEmployees(), employee1, employee2); Assert.assertEquals(department2, employee1.getDepartment()); Assert.assertEquals(department2, employee2.getDepartment()); department2.getEmployees().remove(department2.getEmployees().iterator().next()); AssociationTests.assertCollection(department1.getEmployees()); AssociationTests.assertCollection(department2.getEmployees(), employee2); Assert.assertNull(employee1.getDepartment()); Assert.assertEquals(department2, employee2.getDepartment()); department2.getEmployees().remove(department2.getEmployees().iterator().next()); AssociationTests.assertCollection(department1.getEmployees()); AssociationTests.assertCollection(department2.getEmployees()); Assert.assertNull(employee1.getDepartment()); Assert.assertNull(employee2.getDepartment()); }
private void setDepartment(Department department) { geographicalDepartment.setValue(department != null ? department.getParent().getId() : null); this.department.setValue(department != null ? department.getId() : null); }
public Department getAgency() { if (department != null) { return department.getAgency(); } return null; }