Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.reflect.Method;
- import java.util.Date;
- import java.util.Set;
- import java.util.UUID;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import com.jcom1.api.constants.Constants;
- import com.jcom1.api.dto.ProcessDescriptionBean;
- import com.jcom1.api.dto.init.InitProcessInstanceData;
- import com.jcom1.api.dto.interfaces.IProcessInstanceBean;
- import com.jcom1.api.dto.interfaces.IStorageInstanceBean;
- import com.jcom1.api.dto.interfaces.ISubjectInstanceBean;
- import com.jcom1.api.interfaces.IBo20AccessApi;
- import com.jcom1.api.interfaces.ICommonApi;
- import com.jcom1.runtime.refinement.AbstractRefinement;
- import com.jcom1.runtime.refinement.FunctionStateRequest;
- import com.jcom1.runtime.refinement.FunctionStateResponse;
- import com.jcom1.runtime.refinement.RefinementGenerator;
- import de.metasonic.businessobjects.model.interfaces.IView;
- @RefinementGenerator(id = "InternalSubjectDescription_XkdYwSyHEeaz1PLMMRSyYw")
- public class proc2Subj1Refinement extends AbstractRefinement {
- /**
- * @generated
- */
- private final static Log log = LogFactory
- .getLog("com.jcom1.refinement.process2.proc2subj1");
- @Autowired
- ICommonApi commonApi;
- @Autowired
- IBo20AccessApi accessApi;
- /**
- * This method is called when the named function state is reached State:
- * State3 StateType: FUNCTION
- *
- * Return values "FunctionTransitionDescription_jxVlUSyHEeaz1PLMMRSyYw" when
- * result is "" to go to state State1
- *
- * @return return the id of the transition to follow e.g. // return new
- * FunctionStateResponse("transitionXXXXXXXX");
- */
- @RefinementGenerator(id = "FunctionStateDescription_gSVH0yyHEeaz1PLMMRSyYw")
- public FunctionStateResponse functionState3(
- FunctionStateRequest functionStateRequest) {
- log.debug("start");
- String procDescId = "ProcessDescription_oJIX8Su2EeaVpLwktGFxww";
- try {
- String procVersId = null;
- long maxUploadTime = 0;
- ProcessDescriptionBean[] procDescBeans = commonApi
- .getProcessVersions(procDescId);
- for (ProcessDescriptionBean procDescBean : procDescBeans) {
- long uploadTime = procDescBean.getUploadDate();
- boolean isProductive = procDescBean.isProductive();
- if (isProductive && uploadTime > maxUploadTime) {
- maxUploadTime = uploadTime;
- procVersId = procDescBean.getVersion();
- log.trace("procVersId: " + procVersId);
- }
- }
- String procName = "Process1 / " + new Date();
- String subjInstId = functionStateRequest.getSubjectInstanceId();
- ISubjectInstanceBean subjInstBean = commonApi
- .getSubjectInstanceBean(subjInstId);
- String creatorId = subjInstBean.getEditor();
- int priority = 3;
- log.debug("subjInstId: " + subjInstId);
- log.debug("creatorId: " + creatorId);
- InitProcessInstanceData initProcInstDat = new InitProcessInstanceData();
- initProcInstDat.setProcessVersionId(procVersId);
- initProcInstDat.setMode(Constants.Process.Mode.PRODUCTIVE);
- initProcInstDat.setName(procName);
- initProcInstDat.setCreatorId(creatorId);
- initProcInstDat.setPriority(priority);
- String procInstId = commonApi
- .createProcessInstance(initProcInstDat);
- log.debug("procInstId:" + procInstId);
- IProcessInstanceBean procInstBean = commonApi
- .getProcessInstanceBean(procInstId);
- String[] subjInstIds = procInstBean.getSubjectInstances();
- log.debug("subjInstIds[0]: " + subjInstIds[0]);
- ISubjectInstanceBean subjInstBeanNew = commonApi
- .getSubjectInstanceBean(subjInstIds[0]);
- Set<IStorageInstanceBean> storeInstBeans = accessApi.getStorages(
- subjInstBeanNew, null);
- IStorageInstanceBean storeInstBean = storeInstBeans.iterator()
- .next();
- IView iView = accessApi.createIViewOnStorage(subjInstBeanNew,
- storeInstBean);
- // log.debug("iView.getId():" + iView.getId());
- String string1 = UUID.randomUUID().toString();
- // BO1View bo1View = (BO1View)iView;
- // bo1View.setString1(string1);
- Method[] methods = iView.getClass().getMethods();
- for (Method method : methods) {
- if (method.getName().equals("setString1")) {
- method.invoke(iView, string1);
- break;
- }
- }
- accessApi.saveNewIViewInStorage(subjInstBeanNew, iView,
- storeInstBean);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- // e.printStackTrace();
- log.error(e);
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment