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 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); }