use of org.motechproject.mds.dto.UserPreferencesDto in project motech by motech.
the class EntityServiceImpl method commitChanges.
@Override
@Transactional
public List<String> commitChanges(Long entityId, String changesOwner) {
List<String> modulesToRefresh = new ArrayList<>();
EntityDraft draft = getEntityDraft(entityId, changesOwner);
if (draft.isOutdated()) {
throw new EntityChangedException();
}
entityValidator.validateEntity(draft);
Entity parent = draft.getParentEntity();
String username = draft.getDraftOwnerUsername();
mdsConstructor.removeFields(parent, draft.getFieldsToRemove());
mdsConstructor.updateFields(parent, draft.getFieldNameChanges());
mdsConstructor.removeUniqueIndexes(parent, draft.getUniqueIndexesToDrop());
mdsConstructor.updateRequired(parent, draft.getFieldNameRequired());
comboboxDataMigrationHelper.migrateComboboxDataIfNecessary(parent, draft);
List<UserPreferencesDto> oldEntityPreferences = userPreferencesService.getEntityPreferences(parent.getId());
configureRelatedFields(parent, draft, modulesToRefresh);
parent.updateFromDraft(draft);
updateUserPreferences(parent, draft, oldEntityPreferences);
if (username != null) {
allEntityAudits.createAudit(parent, username);
}
allEntityDrafts.delete(draft);
addModuleToRefresh(parent, modulesToRefresh);
return modulesToRefresh;
}
use of org.motechproject.mds.dto.UserPreferencesDto in project motech by motech.
the class UserPreferencesServiceImpl method getEntityPreferences.
@Override
public List<UserPreferencesDto> getEntityPreferences(Long id) {
Entity entity = getEntity(id);
List<UserPreferences> userPreferences = allUserPreferences.retrieveByClassName(entity.getClassName());
List<UserPreferencesDto> dtos = new ArrayList<>();
Set<String> displayableFields = getDisplayableFields(entity);
if (userPreferences != null) {
Integer defaultGridSize = settingsService.getGridSize();
for (UserPreferences preferences : userPreferences) {
UserPreferencesDto dto = preferences.toDto(displayableFields);
if (dto.getGridRowsNumber() == null) {
dto.setGridRowsNumber(defaultGridSize);
}
dtos.add(dto);
}
}
return dtos;
}
use of org.motechproject.mds.dto.UserPreferencesDto in project motech by motech.
the class UserPreferencesServiceImpl method getUserPreferences.
@Override
@Transactional
public UserPreferencesDto getUserPreferences(Long id, String username) {
Entity entity = getEntity(id);
UserPreferences userPreferences = allUserPreferences.retrieveByClassNameAndUsername(entity.getClassName(), username);
userPreferences = checkPreferences(userPreferences, entity, username);
if (userPreferences != null) {
UserPreferencesDto dto = userPreferences.toDto(getDisplayableFields(entity));
if (dto.getGridRowsNumber() == null) {
dto.setGridRowsNumber(settingsService.getGridSize());
}
return dto;
}
return null;
}
Aggregations