當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。