MyTetra Share
Делитесь знаниями!
Тест этапа ChangeQuery
Время создания: 30.09.2019 11:08
Раздел: INFO - JOB - CUBA - GroovyScripts
Запись: wwwlir/Tetra/master/base/1569812906tozs2nfte0/text.html на raw.githubusercontent.com

//import com.haulmont.cuba.core.global.*;

import com.groupstp.rtneo.entity.*;

import com.haulmont.cuba.core.global.ViewRepository;

import com.haulmont.cuba.core.global.View;


import com.groupstp.rtneo.core.bean.VerificationWorker

import com.groupstp.rtneo.core.bean.changequery.ChangeQueryTools

import com.groupstp.rtneo.core.bean.verification.data.VerificationResult

import com.groupstp.rtneo.entity.*;

import com.groupstp.rtneo.util.ParsingUtil

import com.haulmont.chile.core.model.MetaClass

import com.haulmont.chile.core.model.MetaProperty

import com.haulmont.cuba.core.EntityManager

import com.haulmont.cuba.core.Persistence

import com.haulmont.cuba.core.Transaction

import com.haulmont.cuba.core.global.AppBeans

import com.haulmont.cuba.core.global.DataManager

import com.haulmont.cuba.core.global.Metadata


String id = 'a23935ce-6064-4108-993c-e9b4df03244a';


def context = [:];

context['автопроверка_перемещение'] = null

context['автопроверка'] = null

ViewRepository vRep = AppBeans.get(ViewRepository.NAME)

View changeView = vRep.getView(ChangeQuery.class, "changeQuery-verification");


Metadata metadata = AppBeans.get(Metadata.NAME)

Persistence persistence = AppBeans.get(Persistence.NAME)

ParsingUtil parsing = AppBeans.get(ParsingUtil.NAME)


def entity = dataManager.load(ChangeQuery.class).id(UUID.fromString("${id}")).view(changeView).optional().orElse(null)

log.debug("Entity name - ${entity.getEntityName()}");


MetaClass metaClass = metadata.getClassNN(entity.getEntityName())

log.debug("metaClass -> ${metaClass}");


MetaProperty idProperty = metaClass.getPropertyNN("id")

log.debug("idProperty -> ${idProperty}");


Transaction tr = null

tr = persistence.getTransaction()

EntityManager em = persistence.getEntityManager()

ContragentRealEstate cre = em.find(metaClass.getJavaClass(), parsing.toSimpleValue(entity.getEntityId(), idProperty.getJavaType()), "_local")

log.debug("cre -> ${cre}");

context['автопроверка'] = "отказать"

tr.end();


VerificationWorker worker = AppBeans.get(VerificationWorker.NAME)

def result = worker.verify(entity, context)

Так же в этом разделе:
 
MyTetra Share v.0.55
Яндекс индекс цитирования