Search in sources :

Example 81 with Entity

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

the class EntityServiceImpl method getLookupByName.

@Override
@Transactional
public LookupDto getLookupByName(Long entityId, String lookupName) {
    Entity entity = allEntities.retrieveById(entityId);
    assertEntityExists(entity, entityId);
    Lookup lookup = entity.getLookupByName(lookupName);
    return (lookup == null) ? null : lookup.toDto();
}
Also used : MdsEntity(org.motechproject.mds.domain.MdsEntity) Entity(org.motechproject.mds.domain.Entity) MdsVersionedEntity(org.motechproject.mds.domain.MdsVersionedEntity) Lookup(org.motechproject.mds.domain.Lookup) Transactional(org.springframework.transaction.annotation.Transactional)

Example 82 with Entity

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

the class EntityServiceImpl method getAdvancedSettings.

@Override
@Transactional
public AdvancedSettingsDto getAdvancedSettings(Long entityId, boolean committed) {
    if (committed) {
        Entity entity = allEntities.retrieveById(entityId);
        assertEntityExists(entity, entityId);
        return addNonPersistentAdvancedSettingsData(entity.advancedSettingsDto(), entity, committed);
    } else {
        Entity entity = getEntityDraft(entityId);
        return addNonPersistentAdvancedSettingsData(entity.advancedSettingsDto(), entity, committed);
    }
}
Also used : MdsEntity(org.motechproject.mds.domain.MdsEntity) Entity(org.motechproject.mds.domain.Entity) MdsVersionedEntity(org.motechproject.mds.domain.MdsVersionedEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 83 with Entity

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

the class EntityServiceImpl method deleteEntity.

@Override
@Transactional
public void deleteEntity(Long entityId) {
    Entity entity = allEntities.retrieveById(entityId);
    assertWritableEntity(entity, entityId);
    if (entity.isDraft()) {
        entity = ((EntityDraft) entity).getParentEntity();
    }
    allEntityDrafts.deleteAll(entity);
    allEntities.delete(entity);
}
Also used : MdsEntity(org.motechproject.mds.domain.MdsEntity) Entity(org.motechproject.mds.domain.Entity) MdsVersionedEntity(org.motechproject.mds.domain.MdsVersionedEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 84 with Entity

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

the class EntityServiceImpl method getCurrentSchemaVersion.

@Override
@Transactional
public Long getCurrentSchemaVersion(String className) {
    Entity entity = allEntities.retrieveByClassName(className);
    assertEntityExists(entity, className);
    return entity.getEntityVersion();
}
Also used : MdsEntity(org.motechproject.mds.domain.MdsEntity) Entity(org.motechproject.mds.domain.Entity) MdsVersionedEntity(org.motechproject.mds.domain.MdsVersionedEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 85 with Entity

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

the class EntityServiceImpl method updateSecurityOptions.

@Override
@Transactional
public void updateSecurityOptions(Long entityId, SecurityMode securityMode, Set<String> securityMembers, SecurityMode readOnlySecurityMode, Set<String> readOnlySecurityMembers) {
    Entity entity = allEntities.retrieveById(entityId);
    assertEntityExists(entity, entityId);
    entity.setSecurityMode(securityMode);
    entity.setSecurityMembers(securityMembers);
    entity.setReadOnlySecurityMode(readOnlySecurityMode);
    entity.setReadOnlySecurityMembers(readOnlySecurityMembers);
    allEntities.update(entity);
}
Also used : MdsEntity(org.motechproject.mds.domain.MdsEntity) Entity(org.motechproject.mds.domain.Entity) MdsVersionedEntity(org.motechproject.mds.domain.MdsVersionedEntity) 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