Ejemplo n.º 1
0
  /** @see org.apache.commons.chain.Command#execute(org.apache.commons.chain.Context) */
  @SuppressWarnings("unchecked")
  @Override
  public boolean execute(Context context) throws Exception {
    Object operaterTime = context.get("operaterTime");

    if (operaterTime == null) {
      context.put("code", CodeConstants.INVALID_PARAM);
      context.put(
          "message",
          MessageFormat.format(
              CodeResourcesUtil.getProperty(CodeConstants.INVALID_PARAM), "operaterTime为空"));
      return PROCESSING_COMPLETE;
    }
    try {
      DateUtils.parse(operaterTime.toString(), "yyyyMMddHHmmss");
    } catch (Exception e) {
      context.put("code", CodeConstants.INVALID_PARAM);
      context.put(
          "message",
          MessageFormat.format(
              CodeResourcesUtil.getProperty(CodeConstants.INVALID_PARAM), "operaterTime格式错误"));
      return PROCESSING_COMPLETE;
    }

    return CONTINUE_PROCESSING;
  }
Ejemplo n.º 2
0
  public boolean execute(Context context) throws Exception {
    Session session = ((JCRAppContext) context).getSession();
    String relPath = (String) context.get(pathKey);
    Node parentNode = (Node) session.getItem((String) context.get(currentNodeKey));

    context.put(resultKey, parentNode.getProperty(relPath));
    return false;
  }
Ejemplo n.º 3
0
 @Override
 public void execute(Context ctx) throws RepositoryException {
   Node node = (Node) ctx.get("node");
   if (node.canAddMixin("mix:lockable")) node.addMixin("mix:lockable");
   node.getSession().save();
   node.lock(true, true);
   // node.getSession().save();
 }
Ejemplo n.º 4
0
  @Test
  @SuppressWarnings("unchecked")
  public void testCanCompareStrings() throws Exception {
    String s = "This is a TEST";
    context.put("property", s);

    Eq instance = new Eq("property", "this is a test");
    assertTrue(instance.isTruthValue(context));
  }
Ejemplo n.º 5
0
  @Test
  @SuppressWarnings("unchecked")
  public void testCanCompareBooleans() throws Exception {
    boolean b = true;
    context.put("property", b);

    Eq instance = new Eq("property", "true");
    assertTrue(instance.isTruthValue(context));

    instance = new Eq("property", "false");
    assertFalse(instance.isTruthValue(context));

    b = false;
    context.put("property", b);

    instance = new Eq("property", "false");
    assertTrue(instance.isTruthValue(context));

    instance = new Eq("property", "true");
    assertFalse(instance.isTruthValue(context));
  }
Ejemplo n.º 6
0
  @Test
  @SuppressWarnings("unchecked")
  public void testCanCompareNumbers() throws Exception {
    double number = 123;
    context.put("property", number);

    Eq instance = new Eq("property", "123.00");
    assertTrue(instance.isTruthValue(context));

    instance = new Eq("property", "123.456");
    assertFalse(instance.isTruthValue(context));
  }
Ejemplo n.º 7
0
  /** {@inheritDoc} */
  public boolean execute(Context ctx) throws Exception {
    Node node = CommandHelper.getCurrentNode(ctx);
    String nodeType = (String) ctx.get(this.typeKey);
    String name = (String) ctx.get(this.relPathKey);

    if (log.isDebugEnabled()) {
      log.debug("adding node at " + node.getPath() + "/" + name);
    }

    // If the new node name starts with / add it to the root node
    if (name.startsWith("/")) {
      node = CommandHelper.getSession(ctx).getRootNode();
      name = name.substring(1);
    }

    if (nodeType == null) {
      node.addNode(name);
    } else {
      node.addNode(name, nodeType);
    }
    return false;
  }
Ejemplo n.º 8
0
  @Test
  @SuppressWarnings("unchecked")
  public void testCanCompareCalendars() throws ParseException, Exception {
    Calendar calendar = Calendar.getInstance();
    calendar.set(2009, 0, 15); // month value is 0-based
    context.put("property", calendar);

    Eq instance = new Eq("property", "15/01/2009");
    assertTrue(instance.isTruthValue(context));

    instance = new Eq("property", "01/01/2020");
    assertFalse(instance.isTruthValue(context));
  }
Ejemplo n.º 9
0
  @Test
  @SuppressWarnings("unchecked")
  public void testCanCompareDates() throws ParseException, Exception {
    DateFormat df = new SimpleDateFormat("dd/MM/yyyy'T'HH:mm:ssZ");
    Date date = df.parse("15/01/2009T00:00:00-0000");
    context.put("property", date);

    Eq instance = new Eq("property", "15/01/2009");
    assertTrue(instance.isTruthValue(context));

    instance = new Eq("property", "01/01/2020");
    assertFalse(instance.isTruthValue(context));
  }
 @SuppressWarnings("unchecked")
 private Context getChainContext() throws Exception {
   Context context = new ContextBase();
   context.put("visionOid", this.getFields().get("visionOid"));
   context.put("frequency", this.getFields().get("frequency"));
   context.put("startYearDate", this.getFields().get("year"));
   context.put("endYearDate", this.getFields().get("year"));
   context.put("dateType", this.getFields().get("dateType"));
   context.put("dataFor", BscConstants.MEASURE_DATA_FOR_ORGANIZATION);
   OrganizationVO organization = new OrganizationVO();
   organization.setOid(this.getFields().get("organizationOid"));
   DefaultResult<OrganizationVO> result = this.organizationService.findObjectByOid(organization);
   if (result.getValue() == null) {
     throw new ServiceException(result.getSystemMessage().getValue());
   }
   organization = result.getValue();
   context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL);
   context.put("orgId", organization.getOrgId());
   context.put("uploadSignatureOid", this.getFields().get("uploadSignatureOid"));
   return context;
 }
Ejemplo n.º 11
0
 public void tearDown(Context ctx) throws RepositoryException {
   Node node = (Node) ctx.get("node");
   if (node.isLocked()) node.unlock();
 }