示例#1
0
  private void submitSearch() {
    List<ModelData> query = new ArrayList<ModelData>();

    for (Field<?> field : formFields) {
      ModelData md = new BaseModelData();
      MetaField mf = findField(field.getName());

      if (mf == null
          || !enabledFields.containsKey(mf.getName())
          || field.getValue() == null
          || field.getValue().toString().length() == 0
          || !field.isValid()) {
        GWT.log("Will not submit field " + field.getName() + ".", null);
        continue;
      }

      md.set("field", mf);
      md.set("value", field.getValue());

      query.add(md);
    }

    GWT.log("Submitting search with " + query.size() + " query elements.", null);

    AppEvent evt = new AppEvent(ApplicationEvents.SUBMIT_ADVANCED_SEARCH, query);
    evt.setData("asset", combo.getValue().getBean());
    Dispatcher.forwardEvent(evt);
  }
  /** {@inheritDoc} */
  @Override
  public synchronized int insert(Field field, Plugin plugin) {
    field.setIdField(newPrimaryKey(plugin));
    field.setPosition(newPosition(plugin));

    DAOUtil daoUtil = new DAOUtil(SQL_QUERY_INSERT, plugin);
    daoUtil.setInt(1, field.getIdField());
    daoUtil.setInt(2, field.getEntry().getIdEntry());
    daoUtil.setString(3, field.getTitle());
    daoUtil.setString(4, field.getValue());
    daoUtil.setInt(5, field.getHeight());
    daoUtil.setInt(6, field.getWidth());
    daoUtil.setBoolean(7, field.isDefaultValue());
    daoUtil.setInt(8, field.getMaxSizeEnter());
    daoUtil.setInt(9, field.getPosition());
    daoUtil.setDate(
        10,
        (field.getValueTypeDate() == null) ? null : new Date(field.getValueTypeDate().getTime()));

    daoUtil.setString(11, field.getRoleKey());
    daoUtil.setString(12, field.getWorkgroup());
    daoUtil.setBoolean(13, field.isShownInResultList());
    daoUtil.setBoolean(14, field.isShownInResultRecord());

    daoUtil.executeUpdate();
    daoUtil.free();

    return field.getIdField();
  }
示例#3
0
 /**
  * Returns the value held by the field with the supplied name. This is just a convenience method
  * to save us from an extra method call and cast.
  *
  * @param <T> the desired type of the returned value.
  * @param clazz the desired type of the returned value.
  * @param fieldName the name of the field which value will be retrieved.
  * @return the value held by the field with the supplied name.
  * @throws NoSuchFieldNameException if no field metadata can be found with the specified name.
  * @throws ClassCastException if the type provided is not compatible with the real type of the
  *     requested value.
  */
 public <T extends Serializable> T getValue(Class<T> clazz, String fieldName) {
   int fieldIndex = this.metadata.getFieldIndex(fieldName);
   if (fieldIndex != -1) {
     Field<? extends Object> field = this.data.get(fieldIndex);
     return (T) field.getValue();
   } else {
     throw new NoSuchFieldNameException("No field named " + fieldName);
   }
 }
 protected static String getUniqueMeetingId(MeetingInfo meetingInfo) {
   String uniqueMeetingId = "";
   for (Field field : meetingInfo.getMeetingFields()) {
     if (field.getName().equals("uniqueMeetingId")) {
       uniqueMeetingId = field.getValue();
     }
   }
   return uniqueMeetingId;
 }
示例#5
0
 private String field(Issue issue, TicketFields filed) {
   Field field = issue.getFieldByName(filed.getName());
   if (field != null) {
     Object fieldValue = field.getValue();
     if (fieldValue != null) {
       return fieldValue.toString();
     }
   }
   return "";
 }
示例#6
0
  @Override
  protected String doRender(Field field, Locale locale, int valueIndex) {
    Serializable value = field.getValue(locale, valueIndex);

    if (Validator.isNull(value)) {
      return StringPool.BLANK;
    }

    Format format = FastDateFormatFactoryUtil.getDate(locale);

    return format.format(value);
  }
示例#7
0
  /**
   * Get multi headers
   *
   * @return Enumeration of the values, or null if no such header.
   * @param name the case-insensitive field name
   */
  public Collection<String> getValuesCollection(String name) {
    Field field = getField(name);
    if (field == null) return null;

    final List<String> list = new ArrayList<String>();

    while (field != null) {
      list.add(field.getValue());
      field = field._next;
    }
    return list;
  }
示例#8
0
 private void setUpdatedFields(User user, Fields fields) throws Exception {
   ObjectMapper objectMapper = new ObjectMapper();
   for (Field field : fields.getFields()) {
     BeanUtils.setProperty(user, field.getName(), field.getValue());
   }
   Long currentTime = System.currentTimeMillis();
   String targetUserId = user.getId();
   String targetUserName = objectMapper.writeValueAsString(fields);
   String targetUrl = null;
   Target target = new Target(IdType.USER_ID.toString(), targetUserName, targetUrl);
   Event followedUSerEvent =
       new Event(AuditEventType.USER_UPDATED.toString(), target, currentTime, false);
   auditEventDao.addEvent(targetUserId, followedUSerEvent);
 }
  protected void validateDDMStructureFields(long ddmStructureId, Fields fields)
      throws PortalException {

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.getDDMStructure(ddmStructureId);

    for (Field field : fields) {
      if (!ddmStructure.hasField(field.getName())) {
        throw new StorageFieldNameException();
      }

      if (ddmStructure.getFieldRequired(field.getName()) && Validator.isNull(field.getValue())) {

        throw new StorageFieldRequiredException();
      }
    }
  }
  private void setStoreValue(PrefPanel pp, String name, PersistentBean bean, boolean inheritable) {
    if (bean == null) return;

    Field fld = pp.getField(name);
    Object newValue = fld.getValue();

    // if (newValue == null) return; // LOOK remove from store ??

    // if it matches whats already stored (inherited or not), dont need to store it
    Object oldValue = bean.getObject(name);
    if (newValue == oldValue) return;
    if ((newValue != null) && newValue.equals(oldValue)) return;

    // otherwise store it
    if (!inheritable) bean.putObject(name, newValue);
    else if (isInheritable(fld)) bean.putObject("localMetadataInheritable." + name, newValue);
    else bean.putObject("localMetadata." + name, newValue);
  }
示例#11
0
文件: test.java 项目: khelsen/jacob
  public static void printRS(Recordset rs) {
    Fields fs = rs.getFields();

    for (int i = 0; i < fs.getCount(); i++) {
      System.out.print(fs.getItem(i).getName() + " ");
    }
    System.out.println("");

    rs.MoveFirst();
    while (!rs.getEOF()) {
      for (int i = 0; i < fs.getCount(); i++) {
        Field f = fs.getItem(i);
        Variant v = f.getValue();
        System.out.print(v + " ");
      }
      System.out.println("");
      rs.MoveNext();
    }
  }
示例#12
0
 /* -------------------------------------------------------------- */
 public String toString() {
   try {
     StringBuffer buffer = new StringBuffer();
     for (int i = 0; i < _fields.size(); i++) {
       Field field = (Field) _fields.get(i);
       if (field != null) {
         String tmp = field.getName();
         if (tmp != null) buffer.append(tmp);
         buffer.append(": ");
         tmp = field.getValue();
         if (tmp != null) buffer.append(tmp);
         buffer.append("\r\n");
       }
     }
     buffer.append("\r\n");
     return buffer.toString();
   } catch (Exception e) {
     LOG.warn(e);
     return e.toString();
   }
 }
 /** {@inheritDoc} */
 @Override
 public void store(Field field, Plugin plugin) {
   DAOUtil daoUtil = new DAOUtil(SQL_QUERY_UPDATE, plugin);
   daoUtil.setInt(1, field.getIdField());
   daoUtil.setInt(2, field.getEntry().getIdEntry());
   daoUtil.setString(3, field.getTitle());
   daoUtil.setString(4, field.getValue());
   daoUtil.setInt(5, field.getHeight());
   daoUtil.setInt(6, field.getWidth());
   daoUtil.setBoolean(7, field.isDefaultValue());
   daoUtil.setInt(8, field.getMaxSizeEnter());
   daoUtil.setInt(9, field.getPosition());
   daoUtil.setDate(
       10,
       (field.getValueTypeDate() == null) ? null : new Date(field.getValueTypeDate().getTime()));
   daoUtil.setString(11, field.getRoleKey());
   daoUtil.setString(12, field.getWorkgroup());
   daoUtil.setBoolean(13, field.isShownInResultList());
   daoUtil.setBoolean(14, field.isShownInResultRecord());
   daoUtil.setInt(15, field.getIdField());
   daoUtil.executeUpdate();
   daoUtil.free();
 }
示例#14
0
  public Bar(Set<Field<?>> fields) {
    super(fields);

    for (Field<?> f : fields) {

      if (f.getName().equalsIgnoreCase(Field.Name.VOLUME.field()))
        this.volume = (Integer) f.getValue();

      if (f.getName().equalsIgnoreCase(Field.Name.HIGH.field()))
        this.high = (BigDecimal) f.getValue();

      if (f.getName().equalsIgnoreCase(Field.Name.LOW.field()))
        this.low = (BigDecimal) f.getValue();

      if (f.getName().equalsIgnoreCase(Field.Name.OPEN.field()))
        this.open = (BigDecimal) f.getValue();

      if (f.getName().equalsIgnoreCase(Field.Name.CLOSE.field()))
        this.close = (BigDecimal) f.getValue();

      if (f.getName().equalsIgnoreCase(Field.Name.INTERVAL.field()))
        this.interval = (String) f.getValue();
    }
  }
示例#15
0
  private int saveNewRecord(SqlConn con) throws SQLException {

    // CREATE STMT TO INSERT NEW ENTRY INTO DB
    StringBuilder sb = new StringBuilder("insert into " + table + "(");
    for (Field field : fields.values()) {
      if (field.getValue() == null) continue;
      logger.info(
          "adding field to insert clause: " + field.name + " val: " + field.getValueAsString());
      sb.append(field.name + ",");
    }
    sb.deleteCharAt(sb.length() - 1);
    sb.append(") values (");

    for (Field field : fields.values()) {
      if (field.getValue() == null) continue;
      if (field.getType() == DAOutils.PASSWORD_TYPE) {
        sb.append("password(?),");
      } else {
        sb.append("?,");
      }
    }
    sb.deleteCharAt(sb.length() - 1);
    sb.append(")");

    // FILL STMT TO INSERT NEW ENTRY INTO DB
    int ind = 1;
    logger.info("save dao new " + sb.toString());
    con.prepareStatement(sb.toString());
    for (Field field : fields.values()) {

      if (field.getValue() == null) continue;
      switch (field.getType()) {
        case DAOutils.STRING_TYPE:
          con.setString(ind++, field.getValueAsString());
          break;
        case DAOutils.INT_TYPE:
          con.setInt(ind++, field.getValueAsInt());
          break;
        case DAOutils.TIMESTAMP_TYPE:
          con.setTimestamp(ind++, (Timestamp) field.getValue());
          break;
        case DAOutils.FLOAT_TYPE:
          con.setFloat(ind++, ((Float) field.getValue()).floatValue());
          break;
        case DAOutils.DATE_TYPE:
          con.setDate(ind++, (Date) field.getValue());
          break;
        case DAOutils.PASSWORD_TYPE:
          logger.info("password is " + field.getValueAsString());
          con.setString(ind++, field.getValueAsString());
          break;
        case DAOutils.BLOB_TYPE:
          con.setBlob(ind++, (Blob) field.getValue());
          break;
      }
    }

    // EXECUTE UPDATE
    con.exPrep();

    // IF NEW INSERTION OF AUTO-INCREMENT PRIMARY KEY, RETURN THE AUTO-ID
    if (fields.get(PK).getType() == DAOutils.INT_TYPE && fields.get(PK).getValue() == null) {
      int id = con.getLastSerial(table, PK);
      return id;
    }

    return -1;
  }
示例#16
0
  /* (non-Javadoc)
   * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource)
   */
  public void parse(InputSource inputSource) throws IOException, SAXException {
    if (contentHandler == null) {
      throw new IllegalStateException("'contentHandler' not set.  Cannot parse Record stream.");
    }
    if (execContext == null) {
      throw new IllegalStateException("'execContext' not set.  Cannot parse Record stream.");
    }

    try {
      Reader recordReader;

      // Create the record parser....
      RecordParser recordParser = parserFactory.newRecordParser();
      recordParser.setRecordParserFactory(parserFactory);
      recordParser.setDataSource(inputSource);

      // Start the document and add the root "record-set" element...
      contentHandler.startDocument();
      contentHandler.startElement(
          XMLConstants.NULL_NS_URI, rootElementName, StringUtils.EMPTY, EMPTY_ATTRIBS);

      // Output each of the CVS line entries...
      int lineNumber = 0;

      Record record = recordParser.nextRecord();
      while (record != null) {
        lineNumber++; // First line is line "1"

        if (record != null) {
          List<Field> recordFields = record.getFields();

          if (indent) {
            contentHandler.characters(INDENT_LF, 0, 1);
            contentHandler.characters(INDENTCHARS, 0, 1);
          }

          AttributesImpl attrs = new AttributesImpl();
          attrs.addAttribute(
              XMLConstants.NULL_NS_URI,
              RECORD_NUMBER_ATTR,
              RECORD_NUMBER_ATTR,
              "xs:int",
              Integer.toString(lineNumber));

          RecordMetaData recordMetaData = record.getRecordMetaData();
          if (recordFields.size() < recordMetaData.getUnignoredFieldCount()) {
            attrs.addAttribute(
                XMLConstants.NULL_NS_URI,
                RECORD_TRUNCATED_ATTR,
                RECORD_TRUNCATED_ATTR,
                "xs:boolean",
                Boolean.TRUE.toString());
          }

          contentHandler.startElement(
              XMLConstants.NULL_NS_URI, record.getName(), StringUtils.EMPTY, attrs);
          for (Field recordField : recordFields) {
            String fieldName = recordField.getName();

            if (indent) {
              contentHandler.characters(INDENT_LF, 0, 1);
              contentHandler.characters(INDENTCHARS, 0, 2);
            }

            contentHandler.startElement(
                XMLConstants.NULL_NS_URI, fieldName, StringUtils.EMPTY, EMPTY_ATTRIBS);

            String value = recordField.getValue();
            contentHandler.characters(value.toCharArray(), 0, value.length());
            contentHandler.endElement(XMLConstants.NULL_NS_URI, fieldName, StringUtils.EMPTY);
          }

          if (indent) {
            contentHandler.characters(INDENT_LF, 0, 1);
            contentHandler.characters(INDENTCHARS, 0, 1);
          }

          contentHandler.endElement(XMLConstants.NULL_NS_URI, record.getName(), StringUtils.EMPTY);
        }

        record = recordParser.nextRecord();
      }

      if (indent) {
        contentHandler.characters(INDENT_LF, 0, 1);
      }

      // Close out the "csv-set" root element and end the document..
      contentHandler.endElement(XMLConstants.NULL_NS_URI, rootElementName, StringUtils.EMPTY);
      contentHandler.endDocument();
    } finally {
      // These properties need to be reset for every execution (e.g. when reader is pooled).
      contentHandler = null;
      execContext = null;
    }
  }
示例#17
0
 /**
  * @return the value of a field, or null if not found. For multiple fields of the same name, only
  *     the first is returned.
  * @param name the case-insensitive field name
  */
 public String getStringField(Buffer name) {
   Field field = getField(name);
   return field == null ? null : field.getValue();
 }
示例#18
0
  private int saveExistingRecord(SqlConn con) throws SQLException {

    // CREATE STMT TO UPDATE ENTRY IN DB
    StringBuilder sb = new StringBuilder("update " + table + " set ");

    for (Field field : fields.values()) {
      if (field.getValue() == null) continue;
      if (field.getType() == DAOutils.PASSWORD_TYPE) {
        sb.append(field.name + "=password(?),");
      } else {
        sb.append(field.name + "=?,");
      }
    }

    sb.deleteCharAt(sb.length() - 1);
    if (fields.get(PK).getType() == DAOutils.STRING_TYPE)
      sb.append(" where " + PK + "='" + fields.get(PK).getValueAsString() + "'");
    else sb.append(" where " + PK + "=" + fields.get(PK).getValueAsInt());

    // FILL STMT TO UPDATE ENTRY IN DB
    int ind = 1;
    con.prepareStatement(sb.toString());
    for (Field field : fields.values()) {

      logger.debug(
          " saving field "
              + field.getName()
              + " with val "
              + field.getValueAsString()
              + " in table "
              + this.table
              + " with doa hash "
              + this.hashCode());
      if (field.getValue() == null) continue;

      switch (field.getType()) {
        case DAOutils.STRING_TYPE:
          con.setString(ind++, field.getValueAsString());
          break;
        case DAOutils.INT_TYPE:
          con.setInt(ind++, field.getValueAsInt());
          break;
        case DAOutils.TIMESTAMP_TYPE:
          con.setTimestamp(ind++, (Timestamp) field.getValue());
          break;
        case DAOutils.FLOAT_TYPE:
          con.setFloat(ind++, ((Float) field.getValue()).floatValue());
          break;
        case DAOutils.DATE_TYPE:
          con.setDate(ind++, (Date) field.getValue());
          break;
        case DAOutils.PASSWORD_TYPE:
          con.setString(ind++, field.getValueAsString());
          break;
        case DAOutils.BLOB_TYPE:
          con.setBlob(ind++, (Blob) field.getValue());
      }
    }

    // EXECUTE UPDATE
    con.exPrep();

    // IF STRING TYPE PK, WE KNOW WE'RE NOT DOING AUTO-INCREMENT,
    // SO IGNORE RETURNING A REAL INT.
    if (fields.get(PK).getType() == DAOutils.STRING_TYPE) return 0;

    return getValueAsInt(PK);
  }
  @Test
  public void verifyResult() {

    BasicPackageCreationExample basicPackageCreationExample =
        new BasicPackageCreationExample(Props.get());
    basicPackageCreationExample.run();

    DocumentPackage documentPackage = basicPackageCreationExample.getRetrievedPackage();

    // Verify if the package is created correctly.
    assertFalse(
        "Package enableInPerson setting was not set correctly.",
        documentPackage.getSettings().getEnableInPerson());

    assertThat(
        "Package description was not set correctly.",
        documentPackage.getDescription(),
        is("This is a package created using the e-SignLive SDK"));
    assertThat(
        "Package expiry date was not set correctly.",
        documentPackage.getExpiryDate(),
        is(now().plusMonths(1).toDate()));
    assertThat(
        "Package message was not set correctly.",
        documentPackage.getPackageMessage(),
        is("This message should be delivered to all signers"));

    // Verify if the sdk version is set correctly
    assertThat("Package attributes are null", documentPackage.getAttributes(), is(notNullValue()));
    assertThat(
        "Package attributes are empty",
        documentPackage.getAttributes().getContents(),
        is(notNullValue()));
    assertThat(
        "SDK version was not set",
        documentPackage.getAttributes().toMap().containsKey("sdk"),
        is(true));
    assertThat(
        "SDK version was not set to the correct value",
        documentPackage.getAttributes().toMap().get("sdk").toString(),
        is(equalTo("Java v" + VersionUtil.getVersion())));

    // Signer 1
    Signer signer = documentPackage.getSigner(basicPackageCreationExample.email1);

    assertThat("Signer 1 ID was not set correctly.", signer.getId(), is("Client1"));
    assertThat("Signer 1 first name was not set correctly.", signer.getFirstName(), is("John"));
    assertThat("Signer 1 last name was not set correctly.", signer.getLastName(), is("Smith"));
    assertThat("Signer 1 title was not set correctly.", signer.getTitle(), is("Managing Director"));
    assertThat("Signer 1 company was not set correctly.", signer.getCompany(), is("Acme Inc."));

    // Signer 2
    signer = documentPackage.getSigner(basicPackageCreationExample.email2);
    assertThat("Signer 2 first name was not set correctly.", signer.getFirstName(), is("Patty"));
    assertThat("Signer 2 last name was not set correctly.", signer.getLastName(), is("Galant"));

    // Document 1
    Document document = documentPackage.getDocument("First Document pdf");

    Iterator<Signature> signatures = document.getSignatures().iterator();
    Signature signature;
    Field field;

    if (signatures.hasNext()) {
      signature = signatures.next();

      assertThat(
          "Signature's signer Email was not set correctly for First Document.",
          signature.getSignerEmail(),
          is(basicPackageCreationExample.email1));
      assertThat(
          "Signature page was not set correctly for First Document.", signature.getPage(), is(0));

      Iterator<Field> fields = signature.getFields().iterator();
      if (fields.hasNext()) {
        field = fields.next();
        assertThat(
            "Field style for signature was not set correctly in First Document.",
            field.getStyle(),
            is(FieldStyle.UNBOUND_CHECK_BOX));
        assertThat(
            "Field Page number was not set correctly in First Document.", field.getPage(), is(0));
        assertThat(
            "Field value of signature was not set correctly in First Document.",
            field.getValue(),
            is(FieldBuilder.RADIO_SELECTED));
      }
    }

    // Document 2
    document = documentPackage.getDocument("Second Document PDF");
    signatures = document.getSignatures().iterator();

    if (signatures.hasNext()) {
      signature = signatures.next();

      assertThat(
          "Signature's signer Email was not set correctly for Second Document.",
          signature.getSignerEmail(),
          is("*****@*****.**"));
      assertThat(
          "Signature page was not set correctly for Second Document.", signature.getPage(), is(0));

      Iterator<Field> fields = signature.getFields().iterator();
      if (fields.hasNext()) {
        field = fields.next();
        assertThat(
            "First radio button style for signature was not set correctly in Second Document.",
            field.getStyle(),
            is(FieldStyle.UNBOUND_RADIO_BUTTON));
        assertThat(
            "First radio button Page number was not set correctly in Second Document.",
            field.getPage(),
            is(0));
        assertThat(
            "First radio button value of signature was not set correctly in Second Document.",
            field.getValue(),
            is(""));
        assertThat(
            "First radio button group was not set correctly in Second Document.",
            field.getFieldValidator().getOptions().get(0),
            equalTo(basicPackageCreationExample.group1));

        field = fields.next();
        assertThat(
            "Second radio button style for signature was not set correctly in Second Document.",
            field.getStyle(),
            is(FieldStyle.UNBOUND_RADIO_BUTTON));
        assertThat(
            "Second radio button Page number was not set correctly in Second Document.",
            field.getPage(),
            is(0));
        assertThat(
            "Second radio button value of signature was not set correctly in Second Document.",
            field.getValue(),
            is(FieldBuilder.RADIO_SELECTED));
        assertThat(
            "Second radio button group was not set correctly in Second Document.",
            field.getFieldValidator().getOptions().get(0),
            equalTo(basicPackageCreationExample.group1));

        field = fields.next();
        assertThat(
            "Third radio button style for signature was not set correctly in Second Document.",
            field.getStyle(),
            is(FieldStyle.UNBOUND_RADIO_BUTTON));
        assertThat(
            "Third radio button Page number was not set correctly in Second Document.",
            field.getPage(),
            is(0));
        assertThat(
            "Third radio button value of signature was not set correctly in Second Document.",
            field.getValue(),
            is(FieldBuilder.RADIO_SELECTED));
        assertThat(
            "Third radio button group was not set correctly in Second Document.",
            field.getFieldValidator().getOptions().get(0),
            equalTo(basicPackageCreationExample.group2));

        field = fields.next();
        assertThat(
            "Third radio button style for signature was not set correctly in Second Document.",
            field.getStyle(),
            is(FieldStyle.UNBOUND_RADIO_BUTTON));
        assertThat(
            "Third radio button Page number was not set correctly in Second Document.",
            field.getPage(),
            is(0));
        assertThat(
            "Third radio button value of signature was not set correctly in Second Document.",
            field.getValue(),
            is(""));
        assertThat(
            "Third radio button group was not set correctly in Second Document.",
            field.getFieldValidator().getOptions().get(0),
            equalTo(basicPackageCreationExample.group2));
      }
    }
  }