public void map(Place place, Employee employee) {
    List<Mapping> mappings =
        database
            .find(Mapping.class)
            .add(MobeelizerRestrictions.eq("employee", employee.getGuid()))
            .list();
    for (int i = 0; i < mappings.size(); ++i) {
      if (mappings.get(i).getPlace() != null) {
        database.delete(Mapping.class, mappings.get(i).getGuid());
      }
    }

    Mapping mapping = new Mapping();
    mapping.setEmployee(employee.getGuid());
    mapping.setPlace(place.getGuid());
    mapping.setCreatedBy(Engine.getInstance().getUserIdentyfication().getCurrentUser().getId());
    mapping.setCreationDate(new Date());
    database.save(mapping);
  }
 public void removeMapping(Place place, Employee employee) {
   List<Mapping> mappings =
       database
           .find(Mapping.class)
           .add(MobeelizerRestrictions.eq("employee", employee.getGuid()))
           .add(MobeelizerRestrictions.eq("place", place.getGuid()))
           .list();
   for (int i = 0; i < mappings.size(); ++i) {
     database.delete(Mapping.class, mappings.get(i).getGuid());
   }
 }
 public void changeMaping(Employee employee, Equipment equipment) {
   Mapping mapping =
       database
           .find(Mapping.class)
           .add(MobeelizerRestrictions.eq("equipment", equipment.getGuid()))
           .uniqueResult();
   mapping.setEmployee(employee.getGuid());
   mapping.setCreationDate(new Date());
   mapping.setCreatedBy(Engine.getInstance().getUserIdentyfication().getCurrentUser().getId());
   database.save(mapping);
 }
 public Place getEmployeePlace(Employee employee) {
   List<Mapping> mappings =
       database
           .find(Mapping.class)
           .add(MobeelizerRestrictions.eq("employee", employee.getGuid()))
           .list();
   for (int i = 0; i < mappings.size(); ++i) {
     if (mappings.get(i).getPlace() != null) {
       return database.get(Place.class, mappings.get(i).getPlace());
     }
   }
   return null;
 }
  public List<Equipment> findEmployeeEquipment(Employee employee) {
    List<Equipment> equipmentList = new ArrayList<Equipment>();

    List<Mapping> mappings =
        database
            .find(Mapping.class)
            .add(MobeelizerRestrictions.eq("employee", employee.getGuid()))
            .list();
    for (int i = 0; i < mappings.size(); ++i) {
      if (mappings.get(i).getEquipment() != null) {
        equipmentList.add(database.get(Equipment.class, mappings.get(i).getEquipment()));
      }
    }
    return equipmentList;
  }
  public List<Equipment> findOtherEquipment(Employee employee) {
    List<Equipment> equipmentList = database.list(Equipment.class);

    List<Mapping> mappings =
        database
            .find(Mapping.class)
            .add(MobeelizerRestrictions.eq("employee", employee.getGuid()))
            .list();
    for (int i = 0; i < mappings.size(); ++i) {
      for (int j = 0; j < equipmentList.size(); ++j) {
        if (equipmentList.get(j).getGuid().equals(mappings.get(i).getEquipment())) {
          equipmentList.remove(j);
        }
      }
    }
    return equipmentList;
  }