当前位置: 首页>>代码示例>>Java>>正文


Java MotechDataService.findById方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:24,代码来源:InstanceServiceImpl.java

示例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;
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:12,代码来源:MDSDataProvider.java

示例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);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:9,代码来源:ActionHandlerServiceImpl.java

示例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;
}
 
开发者ID:motech,项目名称:motech,代码行数:8,代码来源:ActionHandlerServiceImpl.java

示例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;
}
 
开发者ID:motech,项目名称:motech,代码行数:12,代码来源:CsvImporterExporter.java

示例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);
}
 
开发者ID:motech,项目名称:motech,代码行数:13,代码来源:InstanceServiceImpl.java

示例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());
}
 
开发者ID:motech,项目名称:motech,代码行数:5,代码来源:InstanceServiceImpl.java


注:本文中的org.motechproject.mds.service.MotechDataService.findById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。