Package net.datacrow.core.modules

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


     * @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

     * @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

       
        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

        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

     * @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

     * @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

                  }
              }
             
              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

        client.notifyStarted(data.size());
       
        client.notifyMessage(DcResources.getText("msgProcessingModuleItems"));
       
        for (String key : data.keySet()) {
            DcModule module = DcModules.get(key);
           
            client.notifyMessage(DcResources.getText("msgProcessingItemsForX", key));
           
                // for existing module data has to be loaded manually.
                // new modules can use the demo data / default data functionality.
            if (module != null) {
               
                client.notifyMessage(DcResources.getText("msgModuleExistsMergingItems"));
               
                // place the images in the correct folder
                storeImages(key, icons.get(key), true);
                // start the import process
                loadItems(data.get(key), module.getIndex());
               
               
            } else {
                try {
                    client.notifyMessage(DcResources.getText("msgModuleIsNewCreatingItems"));
View Full Code Here

public class AdministrationMenu extends DcMenu {
   
    public AdministrationMenu(DcModule module) {
        super(DcResources.getText("lblAdministration"));
       
        DcModule child = module.getChild();
       
        for (DcPropertyModule pm : DcModules.getPropertyModules(module)) {
            int sourceIdx = pm.isServingMultipleModules() ? pm.getIndex() : pm.getIndex() - module.getIndex();
            if (child != null && child.hasReferenceTo(sourceIdx) && !pm.isServingMultipleModules()) {
                add(pm, module.getObjectName() + " " + pm.getObjectNamePlural());
                add((DcPropertyModule) DcModules.get(sourceIdx + child.getIndex()),
                    child.getObjectName() + " " + DcModules.get(sourceIdx + child.getIndex()).getObjectNamePlural());
            } else {
                add(pm, pm.getObjectNamePlural());
            }
        }

        // add references to property modules for the child
        if (child != null) {
            for (DcPropertyModule pm : DcModules.getPropertyModules(child)) {
                int sourceIdx = pm.isServingMultipleModules() ? pm.getIndex() : pm.getIndex() - child.getIndex();
                if (!module.hasReferenceTo(sourceIdx) && !pm.isServingMultipleModules())
                    add(pm, child.getObjectName() + " " + pm.getObjectNamePlural());
            }
        }
       
        if (module.isTopModule() &&  module.getTemplateModule() != null) {
          addSeparator();
View Full Code Here

TOP

Related Classes of net.datacrow.core.modules.DcModule

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.