Package net.datacrow.core.objects

Examples of net.datacrow.core.objects.DcObject


                for (String[] values : lines) {
                    counter++;
                    if (isCanceled()) break;
                    if (counter == 0) continue;
                   
                    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);
                }
               
                reader.close();
            } catch (Exception e) {
View Full Code Here


            this.module = module;
            this.listener = listener;
        }
   
        private DcObject parseItem(DcModule module, Element eItem) throws Exception {
            DcObject dco = module.getItem();
            dco.setIDs();
            String value;
            // get the object
            for (DcField field : module.getFields()) {
               
                if ((field.isUiOnly() && field.getValueType() != DcRepository.ValueTypes._DCOBJECTCOLLECTION && field.getValueType() != DcRepository.ValueTypes._PICTURE) || 
                     field.getIndex() == DcObject._ID || field.getIndex() == DcObject._SYS_EXTERNAL_REFERENCES) continue;
               
                String fieldName = Converter.getValidXmlTag(field.getSystemName());
                NodeList nlField = eItem.getElementsByTagName(fieldName);
               
                if (nlField == null || nlField.getLength() == 0) continue;
               
                Element eField = (Element) nlField.item(0);
               
                if (field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION) {
                    // retrieve the items by their module name
                    DcModule referenceMod = DcModules.get(field.getReferenceIdx());
                    String referenceName = Converter.getValidXmlTag(referenceMod.getSystemObjectName());
                    NodeList elReferences = eField.getElementsByTagName(referenceName);
                    for (int j = 0; elReferences != null && j < elReferences.getLength(); j++) {
                        // retrieve the values by the display field index (the system display field index)
                        Element eReference = (Element) elReferences.item(j);
                        DcObject reference = referenceMod.getItem();
                        String referenceField = Converter.getValidXmlTag(reference.getField(reference.getSystemDisplayFieldIdx()).getSystemName());
                        NodeList nlRefField = eReference.getElementsByTagName(referenceField);
                        if (nlRefField != null && nlRefField.getLength() > 0) {
                            Node eRefField = nlRefField.item(0);
                            setValue(dco, field.getIndex(), eRefField.getTextContent(), listener);
                        } else {
View Full Code Here

                      Element eItem = (Element) nlItems.item(i);
                     
                      if (eItem.getParentNode() != eTop)
                          continue;
                     
                      DcObject dco = parseItem(module, eItem);
                     
                      DcModule cm = module.getChild();
                      if (cm != null) {
                          String childName = Converter.getValidXmlTag(cm.getSystemObjectName());
                            NodeList nlChildren = eItem.getElementsByTagName(childName);
                           
                            for (int j = 0; nlChildren != null && j < nlChildren.getLength(); j++) {
                                Element eChild = (Element) nlChildren.item(j);
                                dco.addChild(parseItem(cm, eChild));
                            }
                      }
                      listener.notifyProcessed(dco);
                    } catch (Exception e) {
                        listener.notifyMessage(e.getMessage());
View Full Code Here

    }

    @Override
    public DcObject getStorageMedium() {
        DcModule module = DcModules.get(importer.getModule());
        DcObject medium = null;
        if (module.getPropertyModule(DcModules._STORAGEMEDIA) != null) {
            Object sm =  fldStorageMedium.getValue();
            medium = sm instanceof DcObject ? (DcObject) sm : null;
        }
           
View Full Code Here

       
        JLabel lblContainer = ComponentFactory.getLabel(DcResources.getText("lblContainer"));
        fldContainer = ComponentFactory.getReferenceField(DcModules._CONTAINER);
       
        String ID = settings.getString(DcRepository.ModuleSettings.stImportCDContainer);
        DcObject item = DataManager.getItem(DcModules._CONTAINER, ID);
        if (item != null)
            fldContainer.setValue(item);
       
        int idx = DcModules.get(importer.getModule()).getPropertyModule(DcModules._STORAGEMEDIA).getIndex();
        JLabel labelMedium = ComponentFactory.getLabel(DcResources.getText("lblStorageMedium"));
View Full Code Here

     * @throws Exception
     */
    public DcObject query(DcObject dco) throws Exception {
        String link = (String) dco.getValue(DcObject._SYS_SERVICEURL);
        if (link != null && link.length() > 0) {
            DcObject item = getItem(new URL(link));
            setServiceInfo(item);
            return item;
        }

        return null;
View Full Code Here

        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) {
View Full Code Here

        if (Utilities.isEmpty(name)) return null;
       
        // method 1: item is provided and exists
        int moduleIdx = DcModules.getReferencedModule(dco.getField(fieldIdx)).getIndex();
        DcModule module = DcModules.get(moduleIdx);
        DcObject ref = value instanceof DcObject ? (DcObject) value : null;

        // check if we are dealing with an external reference
        if (ref == null && module.getType() == DcModule._TYPE_EXTERNALREFERENCE_MODULE) {

            ref = getExternalReference(moduleIdx, name);
       
        } else if (ref == null && module.getType() != DcModule._TYPE_EXTERNALREFERENCE_MODULE) {
           
            // method 2: simple external reference + display value comparison
            ref = DataManager.getObjectForString(moduleIdx, name);
   
            if (ref == null && fieldIdx != DcObject._SYS_EXTERNAL_REFERENCES) {
                ref = module.getItem();
               
                boolean onlinesearch = false;
                if (module.getType() == DcModule._TYPE_ASSOCIATE_MODULE) {
                    ref.setValue(DcAssociate._A_NAME, name);
                    onlinesearch = ref.getModule().deliversOnlineService() &&
                                   dco.getModule().getSettings().getBoolean(DcRepository.ModuleSettings.stOnlineSearchSubItems)
                } else {
                    ref.setValue(ref.getSystemDisplayFieldIdx(), name);
                }
               
                if (onlinesearch) {
                    OnlineSearchHelper osh = new OnlineSearchHelper(moduleIdx, SearchTask._ITEM_MODE_FULL);
                    DcObject queried = osh.query(ref, name, new int[] {module.getSystemDisplayFieldIdx()});
                    ref = queried != null ? queried : ref;
                    osh.clear();
                }
               
                ref.setIDs();
View Full Code Here

        String sql = "SELECT ID FROM " + extRefModule.getTableName() + " WHERE " +
            "UPPER(" + extRefModule.getField(ExternalReference._EXTERNAL_ID).getDatabaseFieldName() + ") = UPPER(?) AND " +
            "UPPER(" + extRefModule.getField(ExternalReference._EXTERNAL_ID_TYPE).getDatabaseFieldName() + ") = UPPER(?)";
       
        Connection conn = DatabaseManager.getConnection();
        DcObject result = null;
       
        try {
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setString(1, externalID);
            ps.setString(2, type);
View Full Code Here

        }
        return result;
    }
   
    public static DcObject getObjectForString(int module, String reference) {
        DcObject dco = getObjectByExternalID(module, DcRepository.ExternalReferences._PDCR, reference);
        dco = dco == null ? getObjectForDisplayValue(module, reference) : dco;
        return dco;
    }
View Full Code Here

TOP

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

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.