Package net.datacrow.core.objects

Examples of net.datacrow.core.objects.DcField


    public static int getCount(int module, int field, Object value) {
        int count = 0;
       
        try {
            DcModule m = DcModules.get(module);
            DcField f = field > 0 ? m.getField(field) : null;
            String sql;
            if (f == null) {
                sql = "select count(*) from " + m.getTableName();
            } else if (f.getValueType() != DcRepository.ValueTypes._DCOBJECTCOLLECTION) {
                sql = "select count(*) from " + m.getTableName() + " where " + m.getField(field).getDatabaseFieldName() +
                      (value == null ? " IS NULL " : " = ?");
            } else {
                if (value != null) {
                  m = DcModules.get(DcModules.getMappingModIdx(module, f.getReferenceIdx(), field));
                  sql = "select count(*) from " + m.getTableName() + " where " + m.getField(DcMapping._B_REFERENCED_ID).getDatabaseFieldName() + " = ?";
                } else {
                  DcModule mapping = DcModules.get(DcModules.getMappingModIdx(module, f.getReferenceIdx(), field));
                  sql = "select count(*) from " + m.getTableName() + " MAINTABLE where not exists (select " +
                        mapping.getField(DcMapping._A_PARENT_ID).getDatabaseFieldName() + " from " + mapping.getTableName() + " where " +
                        mapping.getField(DcMapping._A_PARENT_ID).getDatabaseFieldName() + " = MAINTABLE.ID)";
                }
            }
View Full Code Here


    public static List<List<String>> getValues(DataFilter df, int[] fields, List<WebFieldDefinition> definitions) {
     
      List<List<String>> result = new ArrayList<List<String>>();
     
      ResultSet rs = null;
      DcField field;
     
      try {
       
        String sql = df.toSQLFlatStructure(fields);
        rs = DatabaseManager.executeSQL(sql);
        List<String> values;
       
        int maxLength;
        String ID;
        String value;
        String previousID = null;
        boolean concat = false;
       
        DcModule module = DcModules.get(df.getModule());
        DcObject template = module.getItem();
         
        while(rs.next()) {
          values = new ArrayList<String>();
          ID = rs.getString("ID");

          // concatenate previous result set (needed for multiple references)
          if (ID.equals(previousID)) {
            values = result.get(result.size() - 1);
            concat = true;
          }
         
          for (int i = 0; i < fields.length; i++) {
            field = module.getField(fields[i]);

            if (!field.isUiOnly() &&
              field.getValueType() != DcRepository.ValueTypes._STRING &&
              field.getValueType() != DcRepository.ValueTypes._DCOBJECTREFERENCE) {

              template.setValue(field.getIndex(), rs.getObject(i+1));
              value = template.getDisplayString(field.getIndex());
            } else {
              value = rs.getString(i + 1);
            }

            if (!concat) {
              maxLength = fields[i] != DcObject._ID ? definitions.get(i).getMaxTextLength() : 0;
              value = value == null ? "" : StringUtils.concatUserFriendly(value, maxLength);
              values.add(value);
            } else if (field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION) {
              value = values.get(i) + ", " + value;
              values.set(i, value);
            }
          }
View Full Code Here

   
    private void correctSettings(DcModule module) {
        int[] fields = getIntArray(DcRepository.ModuleSettings.stOnlineSearchFieldOverwriteSettings);
        Collection<Integer> correctedFields = new ArrayList<Integer>();
        for (int field : fields) {
            DcField fld = module.getField(field);
            if (fld != null)
                correctedFields.add(Integer.valueOf(field));
        }
       
        int i = 0;
View Full Code Here

                properties.load(fis);
                fis.close();
               
                for (Object o : properties.keySet()) {
                    String key = (String) o;
                    DcField field = getField(key);
                   
                    if (field != null) {
                        String value = properties.getProperty(key);
                        IValueEnhancer enhancer;
                        if (idx == _AUTOINCREMENT)
                            enhancer = new AutoIncrementer(field.getIndex());
                        else
                            enhancer = new TitleRewriter();
                       
                        enhancer.parse(value);
                       
View Full Code Here

    /**
     * Initializes the default fields.
     */
    @Override
    protected void initializeFields() {
        addField(new DcField(Picture._A_OBJECTID, getIndex(), "ObjectID",
                false, true, false, false,
                36, ComponentFactory._SHORTTEXTFIELD, getIndex(), DcRepository.ValueTypes._STRING,
                "ObjectID"));
        addField(new DcField(Picture._B_FIELD, getIndex(), "Field",
                false, true, false, false,
                100, ComponentFactory._SHORTTEXTFIELD, getIndex(), DcRepository.ValueTypes._STRING,
                "Field"));
        addField(new DcField(Picture._C_FILENAME, getIndex(), "Filename",
                false, true, true, false, 
                500, ComponentFactory._FILELAUNCHFIELD, getIndex(), DcRepository.ValueTypes._STRING,
                "Filename"));
        addField(new DcField(Picture._D_IMAGE, getIndex(), "Image",
                true, true, true, false, 
                0, ComponentFactory._PICTUREFIELD, getIndex(), DcRepository.ValueTypes._IMAGEICON,
                "Image"));       
        addField(new DcField(Picture._E_HEIGHT, getIndex(), "Height",
                false, true, true, false, 
                0, ComponentFactory._NUMBERFIELD, getIndex(), DcRepository.ValueTypes._LONG,
                "Height"));       
        addField(new DcField(Picture._F_WIDTH, getIndex(), "Width",
                false, true, true, false, 
                0, ComponentFactory._NUMBERFIELD, getIndex(), DcRepository.ValueTypes._LONG,
                "Width"))
        addField(new DcField(Picture._G_EXTERNAL_FILENAME, getIndex(), "External Filename",
                false, true, true, false, 
                500, ComponentFactory._FILELAUNCHFIELD, getIndex(), DcRepository.ValueTypes._STRING,
                "External_Filename"));       
    }
View Full Code Here

        JMenu menuAdmin = ComponentFactory.getMenu(IconLibrary._icoModuleTypeProperty16, DcResources.getText("lblAdministration"));
       
        Collection<DcPropertyModule> modules = new ArrayList<DcPropertyModule>();
        for (DcFieldDefinition definition : module.getFieldDefinitions().getDefinitions()) {
            DcField field = module.getField(definition.getIndex());
            DcPropertyModule pm = DcModules.getPropertyModule(field);
           
            if (pm != null && !modules.contains(pm))
                modules.add(pm);
        }
View Full Code Here

     */
    @Override
    protected void initializeFields() {
        super.initializeFields();

        addField(new DcField(Loan._A_STARTDATE, getIndex(), "Start date",
                false, true, false, false,
                255, ComponentFactory._SHORTTEXTFIELD, getIndex(), DcRepository.ValueTypes._DATE,
                "StartDate"));
        addField(new DcField(Loan._B_ENDDATE, getIndex(), "End date",
                false, true, false, false,
                255, ComponentFactory._SHORTTEXTFIELD, getIndex(), DcRepository.ValueTypes._DATE,
                "EndDate"));
        addField(new DcField(Loan._C_CONTACTPERSONID, getIndex(), "Contact Person",
                false, true, false, false,
                36, ComponentFactory._SHORTTEXTFIELD, getIndex(), DcRepository.ValueTypes._STRING,
                "PersonID"));
        addField(new DcField(Loan._D_OBJECTID, getIndex(), "Object",
                false, true, false, false,
                36, ComponentFactory._SHORTTEXTFIELD, getIndex(), DcRepository.ValueTypes._STRING,
                "ObjectID"));
        addField(new DcField(Loan._E_DUEDATE, getIndex(), "Due Date",
                false, true, false, false,
                50, ComponentFactory._DATEFIELD, getIndex(), DcRepository.ValueTypes._DATE,
                "DueDate"));       
    }
View Full Code Here

   
    @Override
    protected void initializeFields() {
        super.initializeFields();
       
        addField(new DcField(DcAssociate._A_NAME, getIndex(), "Name",
                false, true, false, true,
                255, ComponentFactory._SHORTTEXTFIELD, getIndex(), DcRepository.ValueTypes._STRING,
                "Name"));
        addField(new DcField(DcAssociate._B_DESCRIPTION, getIndex(), "Description",
                false, true, false, true,
                4000, ComponentFactory._LONGTEXTFIELD, getIndex(), DcRepository.ValueTypes._STRING,
                "Description"));
        addField(new DcField(DcAssociate._C_WEBPAGE, getIndex(), "Webpage",
                false, true, false, true,
                255, ComponentFactory._URLFIELD, getIndex(), DcRepository.ValueTypes._STRING,
                "webpage"));
        addField(new DcField(DcAssociate._D_PHOTO, getIndex(), "Photo",
                true, true, false, false,
                0, ComponentFactory._PICTUREFIELD, getIndex(), DcRepository.ValueTypes._PICTURE,
                "Photo"));
        addField(new DcField(DcAssociate._E_FIRSTNAME, getIndex(), "Firstname",
                false, true, false, true,
                255, ComponentFactory._SHORTTEXTFIELD, getIndex(), DcRepository.ValueTypes._STRING,
                "Firstname"));
        addField(new DcField(DcAssociate._F_LASTTNAME, getIndex(), "Lastname",
                false, true, false, true,
                255, ComponentFactory._SHORTTEXTFIELD, getIndex(), DcRepository.ValueTypes._STRING,
                "Lastname"));
        addField(new DcField(DcAssociate._G_IS_COMPANY, getIndex(), "Company / Organization",
                false, true, false, true,
                0, ComponentFactory._CHECKBOX, getIndex(), DcRepository.ValueTypes._BOOLEAN,
                "company"));
       
        getField(DcObject._ID).setEnabled(false);
View Full Code Here

    public static String getValue(DcObject dco, WebFieldDefinition def, Object value) {
        return getValue(dco, def.getField(), def.getMaxTextLength(), value);
    }

    private static String getValue(DcObject dco, int fieldIdx, int maxTextLength, Object value) {
        DcField field = dco.getField(fieldIdx);
        String s = "";
        s = value != null && field.getValueType() == DcRepository.ValueTypes._PICTURE ?
                    "/mediaimages/" + ((Picture) value).getScaledFilename() :
                    dco.getDisplayString(field.getIndex());

        if (maxTextLength != 0 && field.getValueType() != DcRepository.ValueTypes._PICTURE)
            s = StringUtils.concatUserFriendly(s, maxTextLength);
       
        return s;
    }
View Full Code Here

                entry.setOperator(o);
        }
    }
   
    public void setValue(Object value) {
        DcField field = DcModules.get(selectedModuleIdx).getField(selectedFieldIdx);
       
        Object o = value;
        if (field.getValueType() == DcRepository.ValueTypes._DCOBJECTREFERENCE) {
            o = DataManager.getItem(field.getReferenceIdx(), String.valueOf(value));
        } else if (field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION) {
            Collection<DcObject> references = new ArrayList<DcObject>();
            DcObject reference = DataManager.getItem(field.getReferenceIdx(), String.valueOf(value));
            references.add(reference);
            o = references;
        }
       
        entry.setValue(o);
View Full Code Here

TOP

Related Classes of net.datacrow.core.objects.DcField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.