use of org.motechproject.mds.domain.UserPreferences 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.domain.UserPreferences in project motech by motech.
the class UserPreferencesServiceImpl method unselectFields.
@Override
@Transactional
public void unselectFields(Long id, String username) {
Entity entity = getEntity(id);
UserPreferences userPreferences = allUserPreferences.retrieveByClassNameAndUsername(entity.getClassName(), username);
userPreferences = checkPreferences(userPreferences, entity, username);
Set<Field> fields = new HashSet<>();
fields.addAll(entity.getFields());
userPreferences.setUnselectedFields(fields);
userPreferences.setSelectedFields(new HashSet<Field>());
allUserPreferences.update(userPreferences);
}
use of org.motechproject.mds.domain.UserPreferences in project motech by motech.
the class UserPreferencesServiceImpl method selectFields.
@Override
@Transactional
public void selectFields(Long id, String username) {
Entity entity = getEntity(id);
UserPreferences userPreferences = allUserPreferences.retrieveByClassNameAndUsername(entity.getClassName(), username);
userPreferences = checkPreferences(userPreferences, entity, username);
Set<Field> fields = new HashSet<>();
fields.addAll(entity.getFields());
userPreferences.setSelectedFields(fields);
userPreferences.setUnselectedFields(new HashSet<Field>());
allUserPreferences.update(userPreferences);
}
use of org.motechproject.mds.domain.UserPreferences 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;
}
use of org.motechproject.mds.domain.UserPreferences in project motech by motech.
the class UserPreferencesServiceImpl method selectField.
@Override
@Transactional
public void selectField(Long id, String username, String fieldName) {
Entity entity = getEntity(id);
UserPreferences userPreferences = allUserPreferences.retrieveByClassNameAndUsername(entity.getClassName(), username);
userPreferences = checkPreferences(userPreferences, entity, username);
Field field = entity.getField(fieldName);
assertField(field, entity.getClassName(), fieldName);
userPreferences.selectField(field);
allUserPreferences.update(userPreferences);
}
Aggregations