예제 #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;
  }
예제 #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;
  }
예제 #3
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));
  }
예제 #4
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));
  }
예제 #5
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));
  }
예제 #6
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));
  }
예제 #7
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;
 }