コード例 #1
0
  @Override
  public boolean allowForm(Protocol protocol, ProtocolFormType protocolFormType) {
    boolean allowForm = false;

    try {
      ProtocolForm protocolForm =
          protocolFormDao.getLatestProtocolFormByProtocolIdAndProtocolFormType(
              protocol.getId(), protocolFormType);

      ProtocolFormStatus latestModProtocolFormStatus =
          protocolFormStatusDao.getLatestProtocolFormStatusByFormId(protocolForm.getId());

      if (protocolFormStatusLst.contains(latestModProtocolFormStatus.getProtocolFormStatus())) {
        allowForm = true;
      }
    } catch (Exception e) {
      allowForm = true;
    }

    return allowForm;
  }
コード例 #2
0
  @Override
  public ProtocolFormXmlData creatNewProtocol(ProtocolFormType protocolFormType)
      throws XPathExpressionException, IOException, SAXException {
    Protocol p = new Protocol();
    Date created = new Date();
    p.setCreated(created);
    p.setLocked(false);

    p = protocolDao.saveOrUpdate(p);

    p.setProtocolIdentifier(Long.toString(baseProtocolIdentifier + p.getId()));

    // protocol.metadataxml always start with /protocol/
    // String protocolMetaDataXmlString = "<protocol id=\"" + p.getId() + "\" identifier=\"" +
    // p.getProtocolIdentifier() + "\" type=\""+ protocolFormType.getDescription()
    // +"\"></protocol>";
    String protocolMetaDataXmlString =
        (protocolFormType.equals(ProtocolFormType.NEW_SUBMISSION))
            ? "<protocol id=\""
                + p.getId()
                + "\" identifier=\""
                + p.getProtocolIdentifier()
                + "\"></protocol>"
            : "<protocol id=\""
                + p.getId()
                + "\" identifier=\""
                + p.getProtocolIdentifier()
                + "\" type=\""
                + protocolFormType.getDescription()
                + "\"></protocol>";
    ;

    p.setMetaDataXml(protocolMetaDataXmlString);
    p = protocolDao.saveOrUpdate(p);

    String protocolFormXmlString =
        "<"
            + protocolFormType.getBaseTag()
            + " id=\""
            + p.getId()
            + "\" identifier=\""
            + p.getProtocolIdentifier()
            + "\" type=\""
            + protocolFormType.getDescription()
            + "\"></"
            + protocolFormType.getBaseTag()
            + ">";

    ProtocolForm f = new ProtocolForm();
    f.setProtocolFormType(protocolFormType);
    f.setProtocol(p);
    f.setCreated(created);
    f.setMetaDataXml(protocolFormXmlString);
    f.setParent(f);
    f.setLocked(false);

    f = protocolFormDao.saveOrUpdate(f);

    ProtocolFormXmlData fxd = new ProtocolFormXmlData();
    fxd.setProtocolForm(f);
    fxd.setXmlData(protocolFormXmlString);
    fxd.setProtocolFormXmlDataType(protocolFormType.getDefaultProtocolFormXmlDataType());
    fxd.setParent(fxd);
    fxd.setCreated(created);

    fxd = protocolFormXmlDataDao.saveOrUpdate(fxd);

    Map<ProtocolFormXmlDataType, ProtocolFormXmlData> protocolFormXmlDatas =
        new HashMap<ProtocolFormXmlDataType, ProtocolFormXmlData>(0);
    protocolFormXmlDatas.put(protocolFormType.getDefaultProtocolFormXmlDataType(), fxd);
    f.setTypedProtocolFormXmlDatas(protocolFormXmlDatas);

    User currentUser = userService.getCurrentUser();

    protocolFormService.triggerPIAction("CREATE", f, currentUser, null);

    objectAclService.updateObjectAclByUser(Protocol.class, p.getId(), currentUser);
    return fxd;
  }