@Override public String getItemLabel() { String label = getAlias() + " (" + getInstitute().getAlias() + ")"; return (label.length() < 51 ? label : label.substring(0, 49) + "\u2026"); }
@Override public String getDeleteDescription() { return getAlias() + " (" + getInstitute().getAlias() + ")"; }
@Override public ValidationResult validateDeletion(Institute object) { ValidationResult result = new ValidationResult(); long usage = instituteDao.getUsage(object); if (usage > 0L) { result.addError(new ValidationError(usage + " lab" + (usage > 1L ? "s are" : " is") + " associated with institute '" + object.getAlias() + "'")); } return result; }
@Override public void update(Institute institute) throws IOException { authorizationManager.throwIfNonAdmin(); Institute updatedInstitute = get(institute.getId()); updatedInstitute.setAlias(institute.getAlias()); User user = authorizationManager.getCurrentUser(); updatedInstitute.setUpdatedBy(user); instituteDao.update(updatedInstitute); }
public static InstituteDto asDto(@Nonnull Institute from) { InstituteDto dto = new InstituteDto(); dto.setId(from.getId()); dto.setAlias(from.getAlias()); dto.setCreatedById(from.getCreatedBy().getUserId()); dto.setCreationDate(formatDateTime(from.getCreationDate())); dto.setUpdatedById(from.getUpdatedBy().getUserId()); dto.setLastUpdated(formatDateTime(from.getLastUpdated())); return dto; }
public static LabDto asDto(@Nonnull Lab from) { LabDto dto = new LabDto(); dto.setId(from.getId()); dto.setInstituteId(from.getInstitute().getId()); dto.setInstituteAlias(from.getInstitute().getAlias()); dto.setAlias(from.getAlias()); dto.setLabel(from.getItemLabel()); dto.setCreatedById(from.getCreatedBy().getUserId()); dto.setCreationDate(formatDateTime(from.getCreationDate())); dto.setUpdatedById(from.getUpdatedBy().getUserId()); dto.setLastUpdated(formatDateTime(from.getLastUpdated())); return dto; }