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


Java GenericModel类代码示例

本文整理汇总了Java中play.db.jpa.GenericModel的典型用法代码示例。如果您正苦于以下问题:Java GenericModel类的具体用法?Java GenericModel怎么用?Java GenericModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GenericModel类属于play.db.jpa包,在下文中一共展示了GenericModel类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doJob

import play.db.jpa.GenericModel; //导入依赖的package包/类
@Override
public void doJob() throws Exception {
	for (GenericModel object : clipboard.getObjects()) {
		if (object instanceof Study) {
			Study study = (Study) object;
			Download.study(study, tmpDir, Format.dcm, preferMultiframe, niftiMultiframeScript);
		} else if (object instanceof Series) {
			Series series = (Series) object;
			Download.series(series, tmpDir, Format.dcm, preferMultiframe, niftiMultiframeScript);
		}
	}

	File zipFile = new File(String.format("%s.7z", tmpDir.getPath()));
	for (File folder : tmpDir.listFiles()) {
		ProcessBuilder processBuilder = new ProcessBuilder("7za", "a", "-mhe=on", "-mx0", String.format("-p%s", password), zipFile.getPath(), folder.getPath());
		processBuilder.redirectErrorStream(true);
		Logger.info("%s %s", zipFile, folder);
		Process process = processBuilder.start();
		Logger.info(IOUtils.toString(process.getInputStream()));
		Logger.info("" + process.waitFor());
	}
	zipFile.renameTo(getDest());
}
 
开发者ID:mwoodbri,项目名称:MRIdb,代码行数:24,代码来源:ClipboardExporter.java

示例2: getObjects

import play.db.jpa.GenericModel; //导入依赖的package包/类
public Set<GenericModel> getObjects() throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
	Set<GenericModel> objects = new HashSet<GenericModel>();
	for (Item item : items) {
		GenericModel object = item.getModel();
		if (!(object instanceof Series) || !objects.contains(((Series) object).study)) {
			objects.add(object);
		}
	}
	return objects;
}
 
开发者ID:mwoodbri,项目名称:MRIdb,代码行数:11,代码来源:Clipboard.java

示例3: isSatisfied

import play.db.jpa.GenericModel; //导入依赖的package包/类
/**
 *
 * {@inheritDoc}
 */
@Override
public boolean isSatisfied(Object validatedObject, Object value,
        OValContext context, Validator validator) {
    requireMessageVariablesRecreation();
    if (value == null) {
        return true;
    }
    final String[] propertyNames = getPropertyNames(
            ((FieldContext) context).getField().getName());
    final GenericModel model = (GenericModel) validatedObject;
    final Model.Factory factory =  Model.Manager.factoryFor(model.getClass());
    final String keyProperty = StringUtils.capitalize(factory.keyName());
    final Object keyValue = factory.keyValue(model);
    //In case of an update make sure that we won't read the current record from database.
    final boolean isUpdate = (keyValue != null);
    final String entityName = model.getClass().getName();
    final StringBuffer jpql = new StringBuffer("SELECT COUNT(o) FROM ");
    jpql.append(entityName).append(" AS o where ");
    final Object[] values = new Object[isUpdate ? propertyNames.length + 1 :
            propertyNames.length];
    final Class clazz = validatedObject.getClass();
    for (int i = 0; i < propertyNames.length; i++) {
        Field field = getField(clazz, propertyNames[i]);
        field.setAccessible(true);
        try {
            values[i] = field.get(model);
        } catch (Exception ex) {
            throw new UnexpectedException(ex);
        }
        if (i > 0) {
            jpql.append(" And ");
        }
        jpql.append("o.").append(propertyNames[i]).append(" = ? ");
    }
    if (isUpdate) {
        values[propertyNames.length] = keyValue;
        jpql.append(" and ").append(keyProperty).append(" <>  ?");
    }
    return JPQL.instance.count(entityName, jpql.toString(), values) == 0L;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:45,代码来源:UniqueCheck.java


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