Exemple #1
0
  /** Description: */
  public static void makeController() throws Exception {
    Configuration cfg = getCfg();
    Template template = cfg.getTemplate("controller.html");

    // 生成文件设置
    String path =
        getJavaFileRoot()
            + File.separator
            + PropertyUtil.getValue("code.src.controller.root")
            + File.separator
            + key;
    mkdirs(path);
    path += File.separator + upperKey + "Controller.java";
    FileWriter sw = new FileWriter(new File(path));
    WeakHashMap<String, Object> data = new WeakHashMap<String, Object>();
    data.put("packageName", controllerPackagePath); // 包名

    data.put("pagePrefix", urlPrefix.substring(1));

    data.put("urlPrefix", urlPrefix);
    data.put("key", key);
    data.put("UpperKey", upperKey);
    data.put("ZhKey", zhKey);
    data.put("author", author);
    data.put("createDate", createDate);

    data.put("EntityClass", entityPackagePath + "." + upperKey + "Entity");
    data.put("serviceInterFace", servicePackagePath + ".I" + upperKey + "Service");
    data.put("primaryKey", primaryKey.getName());
    data.put("UpperPrimaryKey", StringUtil.upperFirst(primaryKey.getName()));

    template.process(data, sw);
  }
  public void build(String headerText, Fact fact) {

    if (fact instanceof FactData) {
      FactData factData = (FactData) fact;
      widget.setWidget(0, ++col, new SmallLabel("[" + factData.getName() + "]"));
    } else {
      col++;
    }

    widget.setWidget(0, 0, new ClickableLabel(headerText, createAddFieldButton(fact)));

    // Sets row name and delete button.
    for (final Field field : fact.getFieldData()) {
      // Avoid duplicate field rows, only one for each name.
      if (rowIndexByFieldName.doesNotContain(field.getName())) {
        newRow(fact, field.getName());
      }

      // Sets row data
      int fieldRowIndex = rowIndexByFieldName.getRowIndex(field.getName());
      widget.setWidget(fieldRowIndex, col, editableCell(field, fact, fact.getType()));
    }

    if (fact instanceof FactData) {
      DeleteFactColumnButton deleteFactColumnButton = new DeleteFactColumnButton((FactData) fact);

      widget.setWidget(rowIndexByFieldName.amountOrRows() + 1, col, deleteFactColumnButton);
    }
  }
Exemple #3
0
  /**
   * Description: 生成service相关类
   *
   * @throws Exception
   */
  public static void makeService() throws Exception {
    Configuration cfg = getCfg();
    // interface
    Template template = cfg.getTemplate("serviceInterface.html");

    // 生成文件设置
    String path =
        getJavaFileRoot()
            + File.separator
            + PropertyUtil.getValue("code.src.service.root")
            + File.separator
            + key;
    mkdirs(path);
    path += File.separator + "I" + upperKey + "Service.java";
    FileWriter sw = new FileWriter(new File(path));
    WeakHashMap<String, Object> data = new WeakHashMap<String, Object>();
    data.put("packageName", servicePackagePath); // 包名
    data.put("EntityClass", entityPackagePath + "." + upperKey + "Entity");
    data.put("key", key);
    data.put("UpperKey", upperKey);
    data.put("ZhKey", zhKey);
    data.put("primaryKey", primaryKey.getName());
    data.put("UpperPrimaryKey", StringUtil.upperFirst(primaryKey.getName()));
    data.put("PrimaryKeyType", StringUtil.upperFirst(primaryKey.getType()));
    data.put("author", author);
    data.put("createDate", createDate);

    template.process(data, sw);

    // impl
    Template implTemplate = cfg.getTemplate("service.html");
    String serviceImplPackagePath = servicePackagePath + ".impl";
    // 生成文件设置
    String implPath =
        getJavaFileRoot()
            + File.separator
            + PropertyUtil.getValue("code.src.service.root")
            + File.separator
            + key
            + File.separator
            + "impl";
    mkdirs(implPath);
    implPath += File.separator + upperKey + "ServiceImpl.java";
    FileWriter implWriter = new FileWriter(new File(implPath));
    WeakHashMap<String, Object> implData = new WeakHashMap<String, Object>();
    implData.put("packageName", serviceImplPackagePath); // 包名
    implData.put("key", key);
    implData.put("UpperKey", upperKey);
    implData.put("ZhKey", zhKey);
    implData.put("EntityClass", entityPackagePath + "." + upperKey + "Entity");
    implData.put("daoInterFace", daoPackagePath + ".I" + upperKey + "Dao");
    implData.put("serviceInterFace", servicePackagePath + ".I" + upperKey + "Service");
    implData.put("primaryKey", primaryKey.getName());
    implData.put("UpperPrimaryKey", StringUtil.upperFirst(primaryKey.getName()));
    implData.put("PrimaryKeyType", StringUtil.upperFirst(primaryKey.getType()));
    implData.put("author", author);
    implData.put("createDate", createDate);

    implTemplate.process(implData, implWriter);
  }
Exemple #4
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);
  }
 public void read(Object record, Decoder dec) throws IOException {
   Object reuseObj = null;
   if (_reuse) {
     _recordAccess.getField(record, _field.getName(), _field.getPos());
   }
   _recordAccess.addField(
       record, _field.getName(), _field.getPos(), _itemReader.read(reuseObj, dec));
 }
Exemple #6
0
 /** Checks whether all fields are valid. If not, throws an exception */
 private void checkFields(Field[] fields) {
   Set<JsonString> names = new HashSet<JsonString>();
   for (Field f : fields) {
     if (names.contains(f.getName())) {
       throw new IllegalArgumentException("duplicate field names not allowed: " + f.getName());
     }
     names.add(f.getName());
   }
 }
Exemple #7
0
 private void checkWhetherSynchIsNeeded(User user, Fields fields) {
   for (Field field : fields.getFields()) {
     if (field.getName().contains("goodreadsAccessTokenSecret")) {
       initiateGoodreadsSynch(user);
     } else if (field.getName().contains("fbId")) {
       // todo kick off fb stuff
     }
   }
 }
  public void addField(Field field) {
    if (field == null || field.getName() == "*") {
      return;
    }

    if (field instanceof MethodField && aggsFunctions.contains(field.getName())) {
      isAgg = true;
    }

    fields.add(field);
  }
Exemple #9
0
 public static List<Field> removeCommonFields(List<Field> list) {
   List<Field> resList = new ArrayList<Field>();
   for (Field f : list) {
     if (!f.getName().equalsIgnoreCase("updateUser")
         && !f.getName().equalsIgnoreCase("createUser")
         && !f.getName().equalsIgnoreCase("createTime")
         && !f.getName().equalsIgnoreCase("updateTime")
         && !f.getName().equalsIgnoreCase("deleteMark")) {
       resList.add(f);
     }
   }
   return resList;
 }
  /**
   * this method find the start and the end of the search dates pass it to dateparser and process
   *
   * @return
   */
  protected Date[] extractSearchDates() {

    String[] startEnd = new String[2];

    for (Field f : fields) {
      if (f.getName().equals(FIELD_IDENTIFIERS[START_INDEX])) {
        startEnd[0] = f.getContent();
      } else if (f.getName().equals(FIELD_IDENTIFIERS[END_INDEX])) {
        startEnd[1] = f.getContent();
      }
    }

    return DateParser.parseSearchDate(startEnd);
  }
Exemple #11
0
 // generates the 'select' part of the SQL select statement
 public String selectProperties(DataObj d) {
   StringBuilder s = new StringBuilder(1024);
   String name = d.getName();
   s.append("select ");
   boolean firstField = true;
   for (Field f : d.getFields()) {
     if (firstField) {
       firstField = false;
       s.append(name + "." + f.getName() + " ");
     } else {
       s.append(", " + name + "." + f.getName() + " ");
     }
   }
   return s.toString();
 }
  /**
   * This method will first indicate which is the start date and the end date. It will then parse
   * the date to DateParser to get an date object
   *
   * @return
   */
  protected Date[] extractDates() {
    Date[] startEnd = new Date[2];
    for (Field f : fields) {
      if (f.getName().equals(FIELD_IDENTIFIERS[START_INDEX])) {
        startEnd[0] = DateParser.parseDate(f.getContent());

      } else if (f.getName().equals(FIELD_IDENTIFIERS[END_INDEX])) {
        startEnd[1] = DateParser.parseDate(f.getContent());
      }
    }
    if (startEnd[0] != null && startEnd[1] != null) {
      Arrays.sort(startEnd);
    }
    return startEnd;
  }
  /**
   * This method first check the which field is stored in the Field array by comparing with the
   * FieldIdentifiers, the content will be stored in string fields
   *
   * @return
   */
  protected String[] extractStrings() {
    String[] strFields = new String[MemoriCommand.NUM_STRING_FIELDS];

    for (Field f : fields) {
      if (f.getName().equals(FIELD_IDENTIFIERS[NAME_INDEX])) {
        strFields[MemoriCommand.NAME_INDEX] = f.getContent();
      } else if (f.getName().equals(FIELD_IDENTIFIERS[LOCATION_INDEX])) {
        strFields[MemoriCommand.LOCATION_INDEX] = f.getContent();

      } else if (f.getName().equals(FIELD_IDENTIFIERS[DESCRIPTION_INDEX])) {
        strFields[MemoriCommand.DESCRIPTION_INDEX] = f.getContent();
      }
    }
    return strFields;
  }
  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();
      }
    }
  }
Exemple #15
0
  /**
   * Processes the results of ASR when recognition is successful
   *
   * <p>CHANGED WITH RESPECT TO FORMFILLLIB (chapter 5) Changes: - If any of the recognized values
   * is valid for the field (according to the grammar), it is saved as the current value, and it is
   * synchronized with the GUI - If not, the field is interpreted again
   */
  @Override
  public void processAsrResults(ArrayList<String> nBestList, float[] nBestConfidences) {

    Field currentField = form.getField(currentPosition);

    int i = 0;
    Boolean validValue = false;

    // Search in the n best ASR recognition results for a valid value according to the field's
    // grammar
    while (i < nBestList.size() && !validValue) {
      validValue = currentField.isvalid(nBestList.get(i));
      i++;
    }

    // If there is a valid value...
    if (validValue) {
      currentField.setValue(
          nBestList.get(i - 1)); // ... it is set as the current value for the field
      result.put(currentField.getName(), nBestList.get(i - 1));
      try {
        oralToGui(currentField); // and it is synchronized with the GUI
      } catch (MultimodalException e) {
        Toast.makeText(this, e.getReason(), Toast.LENGTH_LONG).show();
        Log.e(LOGTAG, e.getReason());
      }
      moveToNextField();
    }
    // If not...
    else {
      interpretCurrentField(); // ... the field is interpreted again
    }
  }
Exemple #16
0
 static {
   HashMap<String, Field> map = new HashMap<>();
   for (Field field : Field.values()) {
     map.put(field.getName(), field);
   }
   byName = map;
 }
Exemple #17
0
  /**
   * Get the full description of a class by using reflection
   *
   * @param clazz
   * @return
   */
  public static String getDescription(Class<?> clazz) {
    ClassType type = TypeOracle.Instance.getClassType(clazz);
    if (type == null) return clazz.getName() + ": Not Reflection Information available.";

    StringBuilder sb = new StringBuilder();
    printAnnotations(type, sb);
    sb.append(type.getName()).append("\n");
    sb.append("\n");
    sb.append("Fields:").append("\n");
    for (Field field : type.getFields()) {
      printAnnotations(field, sb);
      sb.append(field.getTypeName()).append(" ").append(field.getName()).append("\n");
    }

    sb.append("\n");
    if (type.findConstructor() != null) {
      sb.append("Constructor:").append("\n");
      sb.append(type.findConstructor().toString()).append("\n");
    } else {
      sb.append("No default Contructor\n");
    }

    sb.append("\n");
    sb.append("Methods:").append("\n");
    for (Method method : type.getMethods()) {
      printAnnotations(method, sb);
      sb.append(method.toString()).append("\n");
    }

    return sb.toString();
  }
Exemple #18
0
 public void addFieldDefinition(Field field) {
   if (field == null) {
     return;
   }
   fields.add(field);
   fieldDefinitionMap.put(field.getName(), field);
 }
  @Override
  public void note(TFEvent e) {
    Field color = getModel().getColorField();
    if (color != null && color != oldColor) {
      removeAll();
      final FilterCategoryPanel p =
          new FilterCategoryPanel("Color Legend: '" + color.getName() + "'", color, this);
      add(p);
      Bag<String> data = DBUtils.countValues(getModel().getDB().all(), color);
      p.setData(data);
      p.dataList.addListSelectionListener(
          new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
              ValueFilter f = (ValueFilter) p.defineFilter();
              getModel().setGrayFilter(f, this);
            }
          });

      oldColor = color;
      revalidate();
      return;
    } else if (color == null) {
      removeAll();
    }
    repaint();
  }
Exemple #20
0
  /** @return field object with given name, or null */
  public Field containsField(String name) {
    for (Iterator e = field_vec.iterator(); e.hasNext(); ) {
      Field f = (Field) e.next();
      if (f.getName().equals(name)) return f;
    }

    return null;
  }
 /**
  * get hash to identify tableName/field combination
  *
  * @param field
  * @return
  */
 public int getHash(Field field) {
   return new StringBuilder()
       .append(getTable().getName())
       .append(".")
       .append(field.getName())
       .toString()
       .hashCode();
 }
 @Override
 public String[] getFieldNames() throws DriverException {
   final List<Field> fields1 = getFields();
   ArrayList<String> fieldNames = new ArrayList<String>();
   for (Field field : fields1) {
     fieldNames.add(field.getName());
   }
   return fieldNames.toArray(new String[fieldNames.size()]);
 }
 protected static String getUniqueMeetingId(MeetingInfo meetingInfo) {
   String uniqueMeetingId = "";
   for (Field field : meetingInfo.getMeetingFields()) {
     if (field.getName().equals("uniqueMeetingId")) {
       uniqueMeetingId = field.getValue();
     }
   }
   return uniqueMeetingId;
 }
 @Override
 public int getFieldIndex(String fieldName) throws DriverException {
   for (Field field : getFields()) {
     if (field.getName().equals(fieldName)) {
       return field.getOriginalIndex();
     }
   }
   return -1;
 }
  private void addFieldBindings(Bean bean) {
    for (Field field1 : fields) {
      String field = field1.getName();

      if (!field.equals(IGNORE_FIELD)) {
        bean.bindTo(field, recordElementName + "/" + field);
      }
    }
  }
 public Entity(Element element) {
   name = getStringAttribute(element, NAME, null);
   if (name == null) {
     LOG.warn("Entity does not have a name");
     name = "" + System.nanoTime();
   }
   if (name.indexOf(".") != -1) {
     throw new DataImportHandlerException(
         SEVERE, "Entity name must not have period (.): '" + name);
   }
   if (RESERVED_WORDS.contains(name)) {
     throw new DataImportHandlerException(
         SEVERE,
         "Entity name : '"
             + name
             + "' is a reserved keyword. Reserved words are: "
             + RESERVED_WORDS);
   }
   pk = getStringAttribute(element, "pk", null);
   docRoot = getStringAttribute(element, ROOT_ENTITY, null);
   proc = getStringAttribute(element, PROCESSOR, null);
   dataSource = getStringAttribute(element, DataImporter.DATA_SRC, null);
   allAttributes = getAllAttributes(element);
   List<Element> n = getChildNodes(element, "field");
   for (Element elem : n) {
     Field field = new Field(elem);
     fields.add(field);
     List<Field> l = colNameVsField.get(field.column);
     if (l == null) l = new ArrayList<Field>();
     boolean alreadyFound = false;
     for (Field f : l) {
       if (f.getName().equals(field.getName())) {
         alreadyFound = true;
         break;
       }
     }
     if (!alreadyFound) l.add(field);
     colNameVsField.put(field.column, l);
   }
   n = getChildNodes(element, "entity");
   if (!n.isEmpty()) entities = new ArrayList<Entity>();
   for (Element elem : n) entities.add(new Entity(elem));
 }
Exemple #27
0
  /**
   * Return field with given name
   *
   * @param name
   * @return
   */
  public Field getField(String name) {

    for (Field f : fields) {
      if (f.getName().equals(name)) {
        return f;
      }
    }

    return null;
  }
Exemple #28
0
 /**
  * @param name
  * @return
  */
 public Field getField(String name) {
   // FIXME(?): Should be OK with small lists versus using overhead of a Map.
   for (Field field : fields) {
     if (field.getName().equalsIgnoreCase(name)) {
       return field;
     }
   }
   // System.out.println("Record: " + this);
   // System.out.println("+++ Field not found for field name = " + name);
   return null;
 }
Exemple #29
0
  /**
   * Instantiate from existing field.
   *
   * @param field Field object
   * @param cp constant pool (must contain the same entries as the field's constant pool)
   */
  public FieldGen(Field field, ConstantPoolGen cp) {
    this(field.getAccessFlags(), Type.getType(field.getSignature()), field.getName(), cp);

    Attribute[] attrs = field.getAttributes();

    for (int i = 0; i < attrs.length; i++) {
      if (attrs[i] instanceof ConstantValue)
        setValue(((ConstantValue) attrs[i]).getConstantValueIndex());
      else addAttribute(attrs[i]);
    }
  }
  private void assertValidFieldName(String fieldName) {
    for (Field field : fields) {
      if (field.getName().equals(fieldName)) {
        return;
      }
    }

    String fieldNames = "";
    for (Field field : fields) {
      if (!field.ignore()) {
        if (fieldNames.length() > 0) {
          fieldNames += ", ";
        }
        fieldNames += field.getName();
      }
    }

    throw new SmooksConfigurationException(
        "Invalid field name '" + fieldName + "'.  Valid names: [" + fieldNames + "].");
  }