Ejemplo n.º 1
0
  public Office getOffice(int ofid) {
    for (Office of : offices) {
      if (of.getofid() == ofid) return of;
    }

    return null;
  }
Ejemplo n.º 2
0
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   Employee other = (Employee) obj;
   if (email == null) {
     if (other.email != null) return false;
   } else if (!email.equals(other.email)) return false;
   if (extension == null) {
     if (other.extension != null) return false;
   } else if (!extension.equals(other.extension)) return false;
   if (firstname == null) {
     if (other.firstname != null) return false;
   } else if (!firstname.equals(other.firstname)) return false;
   if (jobtitle == null) {
     if (other.jobtitle != null) return false;
   } else if (!jobtitle.equals(other.jobtitle)) return false;
   if (lastname == null) {
     if (other.lastname != null) return false;
   } else if (!lastname.equals(other.lastname)) return false;
   if (office == null) {
     if (other.office != null) return false;
   } else if (!office.equals(other.office)) return false;
   if (reportsto == null) {
     if (other.reportsto != null) return false;
   } else if (!reportsto.equals(other.reportsto)) return false;
   return true;
 }
Ejemplo n.º 3
0
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((email == null) ? 0 : email.hashCode());
   result = prime * result + ((extension == null) ? 0 : extension.hashCode());
   result = prime * result + ((firstname == null) ? 0 : firstname.hashCode());
   result = prime * result + ((jobtitle == null) ? 0 : jobtitle.hashCode());
   result = prime * result + ((lastname == null) ? 0 : lastname.hashCode());
   result = prime * result + ((office == null) ? 0 : office.hashCode());
   result = prime * result + ((reportsto == null) ? 0 : reportsto.hashCode());
   return result;
 }
Ejemplo n.º 4
0
  @POST
  @Path("/office")
  @Consumes("application/json")
  @Produces("application/json")
  public Office createOffice(Office office) {

    Integer officeId = service.createOffice(office);

    office.setOfficeId(officeId);

    return office;
  }
Ejemplo n.º 5
0
  public static void main(String[] args) {
    String path = System.getProperty("user.dir") + File.separator + "etc";
    File file = new File(path, "employee2.xml");
    Digester digester = new Digester();
    digester.addRuleSet(new EmployeeRuleSet());
    try {
      Employee employee = (Employee) digester.parse(file);
      ArrayList offices = employee.getOffices();
      Iterator iterator = offices.iterator();
      System.out.println("-------------------------------------------------");
      while (iterator.hasNext()) {
        Office office = (Office) iterator.next();
        Address address = office.getAddress();
        System.out.println(office.getDescription());
        System.out.println(
            "Address : " + address.getStreetNumber() + " " + address.getStreetName());
        System.out.println("--------------------------------");
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 6
0
    public Master() throws IOException {
      try {
        readFileToString("commands.txt");
      } catch (IOException e) {
        throw new IOException();
      }

      try {
        readFileToString("wanted.txt");
      } catch (IOException e) {
        throw new IOException();
      }

      ArrayList officesData;
      try {
        officesData = stringTokenizer(readFileToString("offices.txt"));
      } catch (IOException e) {
        throw new IOException();
      }
      currentDay = 0;
      inTransit = new ArrayList();
      newCriminals = new ArrayList();
      offices = new ArrayList();

      overwriteFile("", "log_master.txt");
      overwriteFile("", "log_front.txt");

      for (int i = 1; i < officesData.size(); ) {
        String officeName = (String) officesData.get(i);
        int transmiTime = (new BigDecimal((String) officesData.get(i + 1))).intValue();
        int requiredPostage = (new BigDecimal((String) officesData.get(i + 2))).intValue();
        int maxCap = (new BigDecimal((String) officesData.get(i + 3))).intValue();
        int persuationAmmount = (new BigDecimal((String) officesData.get(i + 4))).intValue();
        int maxPackageLen = (new BigDecimal((String) officesData.get(i + 5))).intValue();

        Office newOffice = new Office();
        newOffice.name = officeName;
        newOffice.transitTime = transmiTime;
        newOffice.postagePrice = requiredPostage;
        newOffice.maxCap = maxCap;
        newOffice.persuationPrice = persuationAmmount;
        newOffice.maxPackageSize = maxPackageLen;

        offices.add(newOffice);
        overwriteFile("", "log_" + officeName + ".txt");

        i = i + 6;
      }
    }
Ejemplo n.º 7
0
 @Override
 protected void postConnect() {
   super.postConnect();
 }
 public void addOffice(Office office) {
   getOffices().add(office);
   office.setCompany(this);
 }