Search in sources :

Example 96 with Entity

use of org.motechproject.mds.domain.Entity 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);
}
Also used : UserPreferences(org.motechproject.mds.domain.UserPreferences) AllUserPreferences(org.motechproject.mds.repository.internal.AllUserPreferences) Entity(org.motechproject.mds.domain.Entity) Field(org.motechproject.mds.domain.Field) Transactional(org.springframework.transaction.annotation.Transactional)

Example 97 with Entity

use of org.motechproject.mds.domain.Entity in project motech by motech.

the class UserPreferencesServiceImpl method removeUserPreferences.

@Override
@Transactional
public void removeUserPreferences(Long id, String username) {
    Entity entity = getEntity(id);
    UserPreferences userPreferences = allUserPreferences.retrieveByClassNameAndUsername(entity.getClassName(), username);
    if (userPreferences != null) {
        allUserPreferences.delete(userPreferences);
    }
}
Also used : UserPreferences(org.motechproject.mds.domain.UserPreferences) AllUserPreferences(org.motechproject.mds.repository.internal.AllUserPreferences) Entity(org.motechproject.mds.domain.Entity) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Entity (org.motechproject.mds.domain.Entity)97 Test (org.junit.Test)35 Field (org.motechproject.mds.domain.Field)33 MdsEntity (org.motechproject.mds.domain.MdsEntity)32 MdsVersionedEntity (org.motechproject.mds.domain.MdsVersionedEntity)32 Transactional (org.springframework.transaction.annotation.Transactional)32 ArrayList (java.util.ArrayList)14 Lookup (org.motechproject.mds.domain.Lookup)12 UserPreferences (org.motechproject.mds.domain.UserPreferences)8 Type (org.motechproject.mds.domain.Type)7 AllUserPreferences (org.motechproject.mds.repository.internal.AllUserPreferences)7 EntityDto (org.motechproject.mds.dto.EntityDto)6 LookupFieldDto (org.motechproject.mds.dto.LookupFieldDto)6 HashMap (java.util.HashMap)5 FieldDto (org.motechproject.mds.dto.FieldDto)5 HashSet (java.util.HashSet)4 EntityDraft (org.motechproject.mds.domain.EntityDraft)4 MotechDataService (org.motechproject.mds.service.MotechDataService)4 Query (javax.jdo.Query)3 FieldSetting (org.motechproject.mds.domain.FieldSetting)3