本文整理汇总了Java中org.motechproject.mds.service.MotechDataService.findById方法的典型用法代码示例。如果您正苦于以下问题:Java MotechDataService.findById方法的具体用法?Java MotechDataService.findById怎么用?Java MotechDataService.findById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.motechproject.mds.service.MotechDataService
的用法示例。
在下文中一共展示了MotechDataService.findById方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstanceValueAsRelatedField
import org.motechproject.mds.service.MotechDataService; //导入方法依赖的package包/类
@Override
public FieldRecord getInstanceValueAsRelatedField(Long entityId, Long fieldId, Long instanceId) {
validateCredentialsForReading(getEntity(entityId));
try {
FieldRecord fieldRecord;
FieldDto field = entityService.getEntityFieldById(entityId, fieldId);
MotechDataService service = DataServiceHelper.getDataService(bundleContext, field.getMetadata(RELATED_CLASS).getValue());
Object instance = service.findById(instanceId);
if (instance == null) {
throw new ObjectNotFoundException(service.getClassType().getName(), instanceId);
}
List<FieldDto> relatedEntityFields = getEntityFieldsByClassName(field.getMetadata(RELATED_CLASS).getValue());
fieldRecord = new FieldRecord(field);
fieldRecord.setValue(parseValueForDisplay(instance, relatedEntityFields));
fieldRecord.setDisplayValue(instance.toString());
return fieldRecord;
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new ObjectReadException(entityId, e);
}
}
示例2: findById
import org.motechproject.mds.service.MotechDataService; //导入方法依赖的package包/类
private Object findById(String type, String idParam) {
Long id = parseId(idParam);
String serviceName = MotechClassPool.getInterfaceName(type);
MotechDataService service = OSGiServiceUtils.findService(bundleContext, serviceName);
if (null != service) {
return service.findById(id);
} else {
getLogger().error("Service %s not found", serviceName);
return null;
}
}
示例3: getRelatedInstance
import org.motechproject.mds.service.MotechDataService; //导入方法依赖的package包/类
private Object getRelatedInstance(MotechDataService relatedClassDataService, Object value) {
if (value.getClass().isAssignableFrom(relatedClassDataService.getClassType())) {
return value;
} else {
Long relatedInstanceId = getRelatedInstanceId(value);
return relatedClassDataService.findById(relatedInstanceId);
}
}
示例4: retrieveEntityInstance
import org.motechproject.mds.service.MotechDataService; //导入方法依赖的package包/类
private Object retrieveEntityInstance(MotechDataService dataService, Long instanceId) throws ActionHandlerException {
Object instance = dataService.findById(instanceId);
if (null == instance) {
throw new ActionHandlerException("Instance does not exists");
}
return instance;
}
示例5: getRelatedObject
import org.motechproject.mds.service.MotechDataService; //导入方法依赖的package包/类
private Object getRelatedObject(Long id, String entityClass) {
MotechDataService dataService = DataServiceHelper.getDataService(getBundleContext(), entityClass);
Object obj = dataService.findById(id);
if (obj == null) {
LOGGER.warn("Unable to find {} instance with id {}. Ignoring, you will have to create this relationship manually",
entityClass, id);
}
return obj;
}
示例6: getInstanceField
import org.motechproject.mds.service.MotechDataService; //导入方法依赖的package包/类
@Override
public Object getInstanceField(Long entityId, Long instanceId, String fieldName) throws InstanceNotFoundException {
EntityDto entity = getEntity(entityId);
MotechDataService service = getServiceForEntity(entity);
validateCredentialsForReading(entity);
Object instance = service.findById(instanceId);
if (instance == null) {
throw new InstanceNotFoundException(String.format("Cannot find instance with id: %d", instanceId));
}
return service.getDetachedField(instance, fieldName);
}
示例7: findRelatedObjectById
import org.motechproject.mds.service.MotechDataService; //导入方法依赖的package包/类
private Object findRelatedObjectById(Object id, MotechDataService service) {
//We need parse id value to the long type
return service.findById(TypeHelper.parseNumber(id, Long.class.getName()).longValue());
}