use of org.motechproject.mds.service.MotechDataService in project motech by motech.
the class InstanceServiceImpl method countRecordsWithFilters.
@Override
public long countRecordsWithFilters(Long entityId, Filters filters) {
EntityDto entity = getEntity(entityId);
validateCredentialsForReading(entity);
MotechDataService service = getServiceForEntity(entity);
return service.countForFilters(filters);
}
use of org.motechproject.mds.service.MotechDataService in project motech by motech.
the class InstanceServiceImpl method deleteAllInstances.
@Override
public void deleteAllInstances(Long entityId) {
EntityDto entity = getEntity(entityId);
validateCredentials(entity);
validateNonEditableProperty(entity);
MotechDataService service = getServiceForEntity(entity);
service.deleteAll();
}
use of org.motechproject.mds.service.MotechDataService in project motech by motech.
the class InstanceServiceImpl method revertInstanceFromTrash.
@Override
public void revertInstanceFromTrash(Long entityId, Long instanceId) {
EntityDto entity = getEntity(entityId);
validateCredentials(entity);
validateNonEditableProperty(entity);
MotechDataService service = getServiceForEntity(entity);
service.revertFromTrash(instanceId);
}
use of org.motechproject.mds.service.MotechDataService in project motech by motech.
the class InstanceServiceImpl method getSingleTrashRecord.
@Override
public EntityRecord getSingleTrashRecord(Long entityId, Long instanceId) {
EntityDto entity = getEntity(entityId);
validateCredentialsForReading(entity);
MotechDataService service = getServiceForEntity(entity);
List<FieldDto> fields = entityService.getEntityFieldsForUI(entityId);
Object instance = trashService.findTrashById(instanceId, entity.getClassName());
Map<String, List<FieldDto>> relatedEntitiesFields = getRelatedEntitiesFields(fields);
return instanceToRecord(instance, entity, fields, service, EntityType.TRASH, relatedEntitiesFields);
}
use of org.motechproject.mds.service.MotechDataService in project motech by motech.
the class DataServiceHelper method getDataService.
/**
* Retrieves {@link org.motechproject.mds.service.MotechDataService} implementation for the
* given entity class. It will throw {@link org.motechproject.mds.exception.entity.ServiceNotFoundException}, in
* case a service for the given entity class cannot be found.
*
* @param bundleContext context of a bundle
* @param entityClass fully qualified class name of an entity
* @return generated {@link org.motechproject.mds.service.MotechDataService} implementation
*/
public static MotechDataService getDataService(BundleContext bundleContext, String entityClass) {
String interfaceName = MotechClassPool.getInterfaceName(entityClass);
MotechDataService dataService = OSGiServiceUtils.findService(bundleContext, interfaceName);
if (dataService == null) {
throw new ServiceNotFoundException(interfaceName);
}
return dataService;
}
Aggregations