Package org.apache.olingo.odata2.ref.model

Examples of org.apache.olingo.odata2.ref.model.Employee


      if (data instanceof Manager) {
        for (Employee employee : ((Manager) data).getEmployees()) {
          employee.setManager(null);
        }
      }
      final Employee employee = (Employee) data;
      if (employee.getManager() != null) {
        employee.getManager().getEmployees().remove(employee);
      }
      if (employee.getTeam() != null) {
        employee.getTeam().getEmployees().remove(employee);
      }
      if (employee.getRoom() != null) {
        employee.getRoom().getEmployees().remove(employee);
      }
      if (data instanceof Manager) {
        dataContainer.getManagers().remove(data);
      }
      dataContainer.getEmployees().remove(data);

    } else if (ENTITYSET_1_2.equals(entitySet.getName())) {
      for (Employee employee : ((Team) data).getEmployees()) {
        employee.setTeam(null);
      }
      dataContainer.getTeams().remove(data);

    } else if (ENTITYSET_1_3.equals(entitySet.getName())) {
      for (Employee employee : ((Room) data).getEmployees()) {
        employee.setRoom(null);
      }
      if (((Room) data).getBuilding() != null) {
        ((Room) data).getBuilding().getRooms().remove(data);
      }
      dataContainer.getRooms().remove(data);
View Full Code Here


      final EdmEntitySet targetEntitySet, final Map<String, Object> targetKeys) throws ODataNotImplementedException,
      ODataNotFoundException, EdmException, ODataApplicationException {
    if (ENTITYSET_1_1.equals(targetEntitySet.getName())) {
      if (ENTITYSET_1_2.equals(sourceEntitySet.getName())) {
        for (Iterator<Employee> iterator = ((Team) sourceData).getEmployees().iterator(); iterator.hasNext();) {
          final Employee employee = iterator.next();
          if (employee.getId().equals(targetKeys.get("EmployeeId"))) {
            employee.setTeam(null);
            iterator.remove();
          }
        }
      } else if (ENTITYSET_1_3.equals(sourceEntitySet.getName())) {
        for (Iterator<Employee> iterator = ((Room) sourceData).getEmployees().iterator(); iterator.hasNext();) {
          final Employee employee = iterator.next();
          if (employee.getId().equals(targetKeys.get("EmployeeId"))) {
            employee.setRoom(null);
            iterator.remove();
          }
        }
      } else if (ENTITYSET_1_4.equals(sourceEntitySet.getName())) {
        for (Iterator<Employee> iterator = ((Manager) sourceData).getEmployees().iterator(); iterator.hasNext();) {
          final Employee employee = iterator.next();
          if (employee.getId().equals(targetKeys.get("EmployeeId"))) {
            employee.setManager(null);
            iterator.remove();
          }
        }
      }
View Full Code Here

  public void writeRelation(final EdmEntitySet sourceEntitySet, final Object sourceData,
      final EdmEntitySet targetEntitySet, final Map<String, Object> targetKeys) throws ODataNotImplementedException,
      ODataNotFoundException, EdmException, ODataApplicationException {
    if (ENTITYSET_1_1.equals(targetEntitySet.getName())) {
      final Employee employee = (Employee) readData(targetEntitySet, targetKeys);
      if (ENTITYSET_1_2.equals(sourceEntitySet.getName())) {
        if (employee.getTeam() != null) {
          employee.getTeam().getEmployees().remove(employee);
        }
        employee.setTeam((Team) sourceData);
        ((Team) sourceData).getEmployees().add(employee);
      } else if (ENTITYSET_1_3.equals(sourceEntitySet.getName())) {
        if (employee.getRoom() != null) {
          employee.getRoom().getEmployees().remove(employee);
        }
        employee.setRoom((Room) sourceData);
        ((Room) sourceData).getEmployees().add(employee);
      } else if (ENTITYSET_1_4.equals(sourceEntitySet.getName())) {
        if (employee.getManager() != null) {
          employee.getManager().getEmployees().remove(employee);
        }
        employee.setManager((Manager) sourceData);
        ((Manager) sourceData).getEmployees().add(employee);
      }

    } else if (ENTITYSET_1_2.equals(targetEntitySet.getName())) {
      final Team team = (Team) readData(targetEntitySet, targetKeys);
View Full Code Here

    }
    return location;
  }

  private Employee getOldestEmployee() {
    Employee oldestEmployee = null;
    for (final Employee employee : dataContainer.getEmployees()) {
      if (oldestEmployee == null || employee.getAge() > oldestEmployee.getAge()) {
        oldestEmployee = employee;
      }
    }
    return oldestEmployee;
  }
View Full Code Here

    if (mediaLinkEntryData == null) {
      throw new ODataNotFoundException(null);
    }

    if (ENTITYSET_1_1.equals(entitySet.getName()) || ENTITYSET_1_4.equals(entitySet.getName())) {
      final Employee employee = (Employee) mediaLinkEntryData;
      if (employee.getImage() == null) {
        throw new ODataNotFoundException(null);
      }
      return new BinaryData(employee.getImage(), employee.getImageType());
    } else if (ENTITYSET_2_1.equals(entitySet.getName())) {
      final Photo photo = (Photo) mediaLinkEntryData;
      return new BinaryData(photo.getImage(), photo.getImageType());
    } else {
      throw new ODataNotImplementedException();
View Full Code Here

    if (mediaLinkEntryData == null) {
      throw new ODataNotFoundException(null);
    }

    if (ENTITYSET_1_1.equals(entitySet.getName()) || ENTITYSET_1_4.equals(entitySet.getName())) {
      final Employee employee = (Employee) mediaLinkEntryData;
      employee.setImage(binaryData.getData());
      employee.setImageType(binaryData.getMimeType());
    } else if (ENTITYSET_2_1.equals(entitySet.getName())) {
      final Photo photo = (Photo) mediaLinkEntryData;
      photo.setImage(binaryData.getData());
      photo.setImageType(binaryData.getMimeType());
    } else {
View Full Code Here

  }

  @Override
  public Object newDataObject(final EdmEntitySet entitySet) throws ODataNotImplementedException, EdmException {
    if (ENTITYSET_1_1.equals(entitySet.getName())) {
      Employee employee = dataContainer.createEmployee();
      employee.setAge(0);
      employee.setLocation(new Location(null, null, null));
      return employee;
    } else if (ENTITYSET_1_2.equals(entitySet.getName())) {
      return dataContainer.createTeam();
    } else if (ENTITYSET_1_3.equals(entitySet.getName())) {
      Room room = dataContainer.createRoom();
View Full Code Here

      if (data instanceof Manager) {
        for (Employee employee : ((Manager) data).getEmployees()) {
          employee.setManager(null);
        }
      }
      final Employee employee = (Employee) data;
      if (employee.getManager() != null) {
        employee.getManager().getEmployees().remove(employee);
      }
      if (employee.getTeam() != null) {
        employee.getTeam().getEmployees().remove(employee);
      }
      if (employee.getRoom() != null) {
        employee.getRoom().getEmployees().remove(employee);
      }
      if (data instanceof Manager) {
        dataContainer.getManagers().remove(data);
      }
      dataContainer.getEmployees().remove(data);

    } else if (ENTITYSET_1_2.equals(entitySet.getName())) {
      for (Employee employee : ((Team) data).getEmployees()) {
        employee.setTeam(null);
      }
      dataContainer.getTeams().remove(data);

    } else if (ENTITYSET_1_3.equals(entitySet.getName())) {
      for (Employee employee : ((Room) data).getEmployees()) {
        employee.setRoom(null);
      }
      if (((Room) data).getBuilding() != null) {
        ((Room) data).getBuilding().getRooms().remove(data);
      }
      dataContainer.getRooms().remove(data);
View Full Code Here

      final EdmEntitySet targetEntitySet, final Map<String, Object> targetKeys) throws ODataNotImplementedException,
      ODataNotFoundException, EdmException, ODataApplicationException {
    if (ENTITYSET_1_1.equals(targetEntitySet.getName())) {
      if (ENTITYSET_1_2.equals(sourceEntitySet.getName())) {
        for (Iterator<Employee> iterator = ((Team) sourceData).getEmployees().iterator(); iterator.hasNext();) {
          final Employee employee = iterator.next();
          if (employee.getId().equals(targetKeys.get("EmployeeId"))) {
            employee.setTeam(null);
            iterator.remove();
          }
        }
      } else if (ENTITYSET_1_3.equals(sourceEntitySet.getName())) {
        for (Iterator<Employee> iterator = ((Room) sourceData).getEmployees().iterator(); iterator.hasNext();) {
          final Employee employee = iterator.next();
          if (employee.getId().equals(targetKeys.get("EmployeeId"))) {
            employee.setRoom(null);
            iterator.remove();
          }
        }
      } else if (ENTITYSET_1_4.equals(sourceEntitySet.getName())) {
        for (Iterator<Employee> iterator = ((Manager) sourceData).getEmployees().iterator(); iterator.hasNext();) {
          final Employee employee = iterator.next();
          if (employee.getId().equals(targetKeys.get("EmployeeId"))) {
            employee.setManager(null);
            iterator.remove();
          }
        }
      }
View Full Code Here

  @Override
  public void writeRelation(final EdmEntitySet sourceEntitySet, final Object sourceData,
      final EdmEntitySet targetEntitySet, final Map<String, Object> targetKeys) throws ODataNotImplementedException,
      ODataNotFoundException, EdmException, ODataApplicationException {
    if (ENTITYSET_1_1.equals(targetEntitySet.getName())) {
      final Employee employee = (Employee) readData(targetEntitySet, targetKeys);
      if (ENTITYSET_1_2.equals(sourceEntitySet.getName())) {
        if (employee.getTeam() != null) {
          employee.getTeam().getEmployees().remove(employee);
        }
        employee.setTeam((Team) sourceData);
        ((Team) sourceData).getEmployees().add(employee);
      } else if (ENTITYSET_1_3.equals(sourceEntitySet.getName())) {
        if (employee.getRoom() != null) {
          employee.getRoom().getEmployees().remove(employee);
        }
        employee.setRoom((Room) sourceData);
        ((Room) sourceData).getEmployees().add(employee);
      } else if (ENTITYSET_1_4.equals(sourceEntitySet.getName())) {
        if (employee.getManager() != null) {
          employee.getManager().getEmployees().remove(employee);
        }
        employee.setManager((Manager) sourceData);
        ((Manager) sourceData).getEmployees().add(employee);
      }

    } else if (ENTITYSET_1_2.equals(targetEntitySet.getName())) {
      final Team team = (Team) readData(targetEntitySet, targetKeys);
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.ref.model.Employee

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.