Package net.datacrow.core.objects

Examples of net.datacrow.core.objects.DcField


    @Override
    public void build() {
        setLayout(layout);
 
        DcModule module = DcModules.get(entry.getModule());
        DcField field = module.getField(entry.getField());
        Operator operator = entry.getOperator();
       
       
        JLabel labelAnd = ComponentFactory.getLabel(entry.getAndOr());
        JLabel labelMod = ComponentFactory.getLabel(module.getLabel());
        JLabel labelFld = ComponentFactory.getLabel(field.getLabel());
        JLabel labelOp = ComponentFactory.getLabel(operator.toString());
        JLabel labelVal = ComponentFactory.getLabel(
                entry.getValue() != null ? entry.getValue().toString() : "");
       
        labelAnd.setPreferredSize(new Dimension(30, 25));
View Full Code Here


                int fldCounter = 0;
                int index = values.indexOf("\t");
                while (index > -1) {
                    String value = values.substring(0, index);
                    if (fldCounter <= fields.length) {
                        DcField field = dco.getField(fields[fldCounter]);
                        if (field.getValueType() == DcRepository.ValueTypes._LONG) {
                            try {
                                dco.setValue(fields[fldCounter], Long.valueOf(value.trim()));
                            } catch (Exception e) {
                                logger.warn("Could not set " + value + " for field " + fields[fldCounter], e);
                            }
View Full Code Here

            int counter = 0;
           
            for (int fieldIdx : getFields()) {
               if (isCanceled()) break;

               DcField field = DcModules.get(moduleIdx).getField(fieldIdx);
               if (field != null) {
                    writeBytes(field.getSystemName(), counter != 0);
                    counter++;
                }               
            }       
           
            writeBytes("\r\n", false);
           
            counter = 0;
           
            for (String item : items) {
             
              DcObject dco = DataManager.getItem(getModule().getIndex(), item);
               
                if (isCanceled()) break;
               
                client.notifyMessage(DcResources.getText("msgExportingX", dco.toString()));
                int fieldCounter = 0;
                Object o;
                String s = "";
                for (int fieldIdx : getFields()) {
                    if (isCanceled()) break;

                    DcField field = DcModules.get(moduleIdx).getField(fieldIdx);
                   
                    if (isCanceled()) break;

                    o = dco.getValue(field.getIndex());
                   
                    if (field != null) {
                        s = "";
                       
                        if (field.getFieldType() == ComponentFactory._PICTUREFIELD) {
                            if (o != null && o.toString().length() >= 10)
                               s = utilities.getImageURL((Picture) dco.getValue(field.getIndex()));
                       
                        } else if (o instanceof Collection &&
                                   DcModules.get(field.getReferenceIdx()).getType() == DcModule._TYPE_ASSOCIATE_MODULE) {
                           
                           for (DcObject subDco : (Collection<DcObject>) o) {
                                if (subDco instanceof DcMapping)
                                    subDco = ((DcMapping) subDco).getReferencedObject();

                                if (subDco != null) {
                                    s += (s.length() > 0 ? ", " : "");
                                    s += ((DcAssociate) subDco).getNameNormal();
                                }
                            }
                        } else {
                            s = dco.getDisplayString(field.getIndex());
                        }
                       
                        writeBytes(s, fieldCounter != 0);
                        fieldCounter++;
                    }
View Full Code Here

        return tab;
    }
   
    public String getTab(int module) {
        if (Utilities.isEmpty(tab)) {
            DcField field = DcModules.get(module).getField(index);
           
            if ((!field.isUiOnly() || field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION) &&
                  field.isEnabled() &&
                  field.getValueType() != DcRepository.ValueTypes._PICTURE && // check the field type
                  field.getValueType() != DcRepository.ValueTypes._ICON &&
                 (index != DcModules.get(module).getParentReferenceFieldIndex() ||
                  index == DcObject._SYS_CONTAINER )) { // not a reference field
               
                tab = "lblInformation";
            }
View Full Code Here

                client.notifyMessage(DcResources.getText("msgExportingX", dco.toString()));

                writer.writeAttribute(dco, DcObject._SYS_MODULE);
               
                for (int fieldIdx : getFields()) {
                    DcField field = dco.getField(fieldIdx);
                    if (field != null) writer.writeAttribute(dco, field.getIndex());
                }

                dco.loadChildren(null);
               
                if (dco.getModule().getChild() != null) {
View Full Code Here

        this.fields = fields;
    }

    private void handle(DcObject dco, Collection<String> handled) throws IOException {
        for (int fieldIdx : fields) {
            DcField field = dco.getField(fieldIdx);
            if (field != null && field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION) {
                DcModule sm = DcModules.get(field.getReferenceIdx());
                DcObject so = sm.getItem();

                if (!handled.contains(so.getModule().getSystemObjectName())) {
                    writeDco(so);
                    newLine();
View Full Code Here

            String label = getValidTag(dco.getField(field).getSystemName());
            writeLine("<xsd:element name=\"" + label + "\" type=\"xsd:string\"/>", 3);
        } else if (dco instanceof DcMediaObject) {
            writeField(dco.getField(DcObject._SYS_MODULE));
            for (int fieldIdx : fields) {
                DcField field = dco.getField(fieldIdx);
                if (field != null) writeField(field);
            }
        }
       
        if (dco.getModule().getChild() != null) {
View Full Code Here

    protected void setValue(DcObject dco, int fieldIdx, String value, IItemImporterClient listener) {
       
        if (Utilities.isEmpty(value)) return;
       
        DcField field = dco.getModule().getField(fieldIdx);
       
        try {
            if (field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION ||
                field.getValueType() == DcRepository.ValueTypes._DCOBJECTREFERENCE) {

                DataManager.createReference(dco, field.getIndex(), value);
               
            } else if (field.getFieldType() == ComponentFactory._TIMEFIELD) {
                try {
                    dco.setValue(field.getIndex(), Long.valueOf(value));
                } catch (NumberFormatException nfe) {
                    if (value.indexOf(":") > -1) {
                        int hours = Integer.parseInt(value.substring(0, value.indexOf(":")));
                        int minutes = Integer.parseInt(value.substring(value.indexOf(":") + 1, value.lastIndexOf(":")));
                        int seconds = Integer.parseInt(value.substring(value.lastIndexOf(":") + 1));
                        dco.setValue(field.getIndex(), Long.valueOf(seconds + (minutes *60) + (hours * 60 * 60)));
                    }
                }
             } else if (field.getFieldType() == ComponentFactory._RATINGCOMBOBOX ||
                        field.getFieldType() == ComponentFactory._FILESIZEFIELD) {
   
                 value = value.replaceAll("\\.", "");
                
                 try {
                     dco.setValue(field.getIndex(), Long.valueOf(value));
                 } catch (NumberFormatException nfe) {
                     String sValue = "";
                     for (char c : value.toCharArray()) {
                         if (Character.isDigit(c))
                             sValue += c;
                         else
                             break;
                     }
                    
                     if (!Utilities.isEmpty(sValue))
                         dco.setValue(field.getIndex(), Long.valueOf(sValue));
                }
            } else if (field.getValueType() == DcRepository.ValueTypes._PICTURE) {
                File file = getImagePath(value);
                if (file.exists())
                    dco.setValue(field.getIndex(), new DcImageIcon(file));
            } else if (field.getValueType() == DcRepository.ValueTypes._ICON) {
                File file = getImagePath(value);
                if (file.exists()) {
                    String s = Utilities.fileToBase64String(file);
                    s = Utilities.isEmpty(s) ? Utilities.fileToBase64String(new File(value)) : s;
                    dco.setValue(field.getIndex(), s);
                } else {
                    dco.setValue(field.getIndex(), value);
                }
            } else if (field.getValueType() == DcRepository.ValueTypes._BOOLEAN) {
                dco.setValue(field.getIndex(), Boolean.valueOf(value));
            } else {
                dco.setValue(field.getIndex(), value);
            }
        } catch (Exception e) {
            String message = DcResources.getText("msgErrorWhileSettingValue", new String[] {value, field.getLabel()});
            listener.notifyMessage(message);
            logger.error(message, e);
        }                            
    }
View Full Code Here

                   
                    DcObject dco = module.getItem();
                    for (int fieldIdx = 0; fieldIdx < values.length; fieldIdx++) {
                       
                        String value = values[fieldIdx];
                        DcField field = mappings.getTarget(fieldIdx);
                       
                        if ((field.isUiOnly() && field.getValueType() != DcRepository.ValueTypes._DCOBJECTCOLLECTION && field.getValueType() != DcRepository.ValueTypes._PICTURE) || 
                            field.getIndex() == DcObject._ID || field.getIndex() == DcObject._SYS_EXTERNAL_REFERENCES) continue;
                       
                        if (value != null && field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION) {
                            StringTokenizer st = new StringTokenizer(value, ",");
                            String s;
                            while (st.hasMoreElements()) {
                                s = (String) st.nextElement();
                                DataManager.createReference(dco, field.getIndex(), s);
                            }
                        } else {
                            setValue(dco, field.getIndex(), value, listener);
                        }
                    }
                   
                    dco.setIDs();
                    listener.notifyProcessed(dco);
View Full Code Here

     * @param fields
     */
    public void setFields(int moduleIdx, Collection<String> fields) {
        DcModule module = DcModules.get(moduleIdx);
        for (String fieldName : fields) {
            DcField target = null;
            for (DcField field : module.getFields()) {
                if (field.getDatabaseFieldName().equals(fieldName) ||
                    field.getLabel().equals(fieldName) ||
                    field.getOriginalLabel().equals(fieldName)) {
                    target = field;
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.