Examples of DcModule


Examples of net.datacrow.core.modules.DcModule

            this.msgID = msgID;
        }
       
        @Override
        public void run() {
            DcModule mod = DcModules.get(module);

            String msg = DcResources.getText(msgID);
            if (mod.getType() == DcModule._TYPE_PROPERTY_MODULE) {
                DcMinimalisticItemView view = ((DcPropertyModule) mod).getForm();
                view.setStatus(msg);
            } else if (mod.getType() == DcModule._TYPE_TEMPLATE_MODULE) {
                DcMinimalisticItemView form = ((TemplateModule) mod).getForm();
                form.setStatus(msg);            
            } else {
                if (tab == MainFrame._INSERTTAB) {
                    mod.getCurrentInsertView().setStatus(msg);
                } else if (tab == MainFrame._SEARCHTAB) {
                    mod.getCurrentSearchView().setStatus(msg);
                }
            }
           
            msg = null;
        }
View Full Code Here

Examples of net.datacrow.core.modules.DcModule

   
    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)";
                }
            }
               
            PreparedStatement ps = DatabaseManager.getConnection().prepareStatement(sql);
           
View Full Code Here

Examples of net.datacrow.core.modules.DcModule

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

Examples of net.datacrow.core.modules.DcModule

     * @param childIdx The child module index.
     * @return The children or an empty collection.
     */
    public static List<DcObject> getChildren(String parentID, int childIdx, int[] fields) {
        DataFilter df = new DataFilter(childIdx);
        DcModule module = DcModules.get(childIdx);
        df.addEntry(new DataFilterEntry(DataFilterEntry._AND, childIdx, module.getParentReferenceFieldIndex(), Operator.EQUAL_TO, parentID));
        return new SelectQuery(df, null, fields).run();
    }
View Full Code Here

Examples of net.datacrow.core.modules.DcModule

     * @param childIdx The child module index.
     * @return The children or an empty collection.
     */
    public static Map<String, Integer> getChildrenKeys(String parentID, int childIdx) {
        DataFilter df = new DataFilter(childIdx);
        DcModule module = DcModules.get(childIdx);
        df.addEntry(new DataFilterEntry(DataFilterEntry._AND, childIdx, module.getParentReferenceFieldIndex(), Operator.EQUAL_TO, parentID));
        return getKeys(df);
    }
View Full Code Here

Examples of net.datacrow.core.modules.DcModule

       
        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

Examples of net.datacrow.core.modules.DcModule

        List<DcObject> items = get(df, new int[] {DcObject._ID});
        return items.size() > 0 ? items.get(0) : null;   
    }   
   
    public static DcObject getObjectByExternalID(int moduleIdx, String type, String externalID) {
        DcModule module =  DcModules.get(moduleIdx);
      
        if (module.getField(DcObject._SYS_EXTERNAL_REFERENCES) == null) return null;
       
        DcModule extRefModule =  DcModules.get(moduleIdx + DcModules._EXTERNALREFERENCE);
        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);
           
            ResultSet rs = ps.executeQuery();
            String referenceID;
            while (rs.next()) {
                referenceID = rs.getString(1);
               
                int idx = DcModules.getMappingModIdx(extRefModule.getIndex() - DcModules._EXTERNALREFERENCE, extRefModule.getIndex(), DcObject._SYS_EXTERNAL_REFERENCES);
                DcModule mappingMod = DcModules.get(idx);
                sql = "SELECT * FROM " + DcModules.get(moduleIdx) + " WHERE ID IN (" +
                    "SELECT OBJECTID FROM " + mappingMod.getTableName() +
                      " WHERE " + mappingMod.getField(DcMapping._B_REFERENCED_ID).getDatabaseFieldName() + " = ?)";
   
                PreparedStatement ps2 = conn.prepareStatement(sql);
                ps2.setString(1, referenceID);
               
                List<DcObject> items = WorkFlow.getInstance().convert(ps2.executeQuery(), new int[] {DcObject._ID});
View Full Code Here

Examples of net.datacrow.core.modules.DcModule

     * @param module
     * @param s The display value.
     * @return Either the item or null.
     */
    private static DcObject getObjectForDisplayValue(int moduleIdx, String s) {
        DcModule module = DcModules.get(moduleIdx);

        try {
          String columns = module.getIndex() + " AS MODULEIDX";
          for (DcField field : module.getFields()) {
            if (!field.isUiOnly())
              columns += "," + field.getDatabaseFieldName();
          }
         
            String query = "SELECT " + columns + " FROM " + module.getTableName() + " WHERE " +
                "RTRIM(LTRIM(UPPER(" + module.getField(module.getSystemDisplayFieldIdx()).getDatabaseFieldName() + "))) =  UPPER(?)";
           
            if (module.getType() == DcModule._TYPE_ASSOCIATE_MODULE)
              query += " OR RTRIM(LTRIM(UPPER(" + module.getField(DcAssociate._A_NAME).getDatabaseFieldName() + "))) LIKE ?";
           
            if (module.getType() == DcModule._TYPE_PROPERTY_MODULE)
                query += " OR RTRIM(LTRIM(UPPER(" + module.getField(DcProperty._C_ALTERNATIVE_NAMES).getDatabaseFieldName() + "))) LIKE ?";
           
            PreparedStatement ps = DatabaseManager.getConnection().prepareStatement(query);

            ps.setString(1, s);
           
            if (module.getType() == DcModule._TYPE_ASSOCIATE_MODULE) {
            String firstname = Utilities.getFirstName(s);
            String lastname = Utilities.getLastName(s);
            ps.setString(2, Utilities.getName(firstname, lastname, false).toUpperCase());
            }
           
            if (module.getType() == DcModule._TYPE_PROPERTY_MODULE)
                ps.setString(2";%" + s.toUpperCase().trim() + "%;");
           
            List<DcObject> items = WorkFlow.getInstance().convert(ps.executeQuery(), new int[] {DcObject._ID});
            return items.size() > 0 ? items.get(0) : null;
           
View Full Code Here

Examples of net.datacrow.core.modules.DcModule

     * @see DataFilter
     * @param filter
     * @param fields
     */
    public static List<DcSimpleValue> getSimpleValues(int module, boolean icons) {
        DcModule m = DcModules.get(module);
        boolean useIcons = icons && m.getIconField() != null;
        String sql = "select ID, " + m.getField(m.getDisplayFieldIdx()).getDatabaseFieldName() +
                      (useIcons ? ", " + m.getIconField().getDatabaseFieldName() : " ")
                     " from " + m.getTableName() +
                     " order by 2";

        List<DcSimpleValue> values = new ArrayList<DcSimpleValue>();
        try {
            ResultSet rs = DatabaseManager.executeSQL(sql);
View Full Code Here

Examples of net.datacrow.core.modules.DcModule

                  }
              }
             
              try {
                  // fake registration to make sure the index is known
                  DcModule module = new DcModule(xm);
                  module.setValid(false);
                  DcModules.register(module);
                    mj.save();
                } catch (ModuleJarException e) {
                    logger.error(e, e);
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.