Package net.datacrow.core.modules

Examples of net.datacrow.core.modules.DcModule


        }
    }
   
    @Override
    protected void createTopNode() {
        DcModule mod = DcModules.get(getModule());
        String label = mod.getObjectNamePlural();
       
        if (isEnabled() && fields != null && fields.length > 0) {
            label += " by ";
            for (int i = 0; i < fields.length; i++)
                label += (i > 0 ? " & " : "") + mod.getField(fields[i]).getLabel();
        }
       
        top = new DcDefaultMutableTreeNode(label);
        top.setUserObject(new NodeElement(null, label, null));
    }
View Full Code Here


        //**********************************************************
        //Tabbed pane
        //**********************************************************
        JTabbedPane tp = ComponentFactory.getTabbedPane();
       
        DcModule module = DcModules.getCurrent();
        fsp = new FieldSelectionPanel(module, false, true, true);
       
        int[] fields = (int[]) module.getSetting(DcRepository.ModuleSettings.stCardViewItemDescription);
        fsp.setSelectedFields(fields);
       
        DcColorSelector csTextBg = ComponentFactory.getColorSelector(DcRepository.Settings.stCardViewBackgroundColor);
        DcColorSelector csOdd = ComponentFactory.getColorSelector(DcRepository.Settings.stOddRowColor);
        DcColorSelector csEven = ComponentFactory.getColorSelector(DcRepository.Settings.stEvenRowColor);
View Full Code Here

         * Creates a flat structure of the tree to be build.
         * The tree is created based on the result one SQL statement.
         * @param fields
         */
        private void createTree(int[] fields) {
            DcModule m = DcModules.get(getModule());

            StringBuffer sql = new StringBuffer("");
           
            List<String> joinOn = new ArrayList<String>();
           
            DcField field;
            DcModule reference;
            DcModule main;
           
            Collection<DcModule> modules = new ArrayList<DcModule>();
           
            if (m.isAbstract()) {
              modules = DcModules.getPersistentModules(m);
            } else {
              modules.add(m);
            }
           
            int moduleCounter = 0;
            int fieldCounter = 0;
           
            StringBuffer columns;
            StringBuffer joins;
           
            for (DcModule module : modules) {
             
              fieldCounter = 0;

              columns = new StringBuffer("select ");
                joins = new StringBuffer("from ");
                joins.append(module.getTableName());
               
              if (moduleCounter > 0)
                sql.append(" UNION ");
             
                columns.append(module.getTableName());
                columns.append(".ID, ");
                columns.append(module.getIndex());
                columns.append(" AS MODULEIDX");     
             
              for (int idx : fields) {
                  field = module.getField(idx);
                  if (field.isUiOnly() &&
                      field.getValueType() != DcRepository.ValueTypes._DCOBJECTCOLLECTION &&
                      field.getValueType() != DcRepository.ValueTypes._DCOBJECTREFERENCE) continue;
                 
                    columns.append(",");
                 
                  joinOn.add(module.getTableName() + fieldCounter + ".ID");
                 
                  if (field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION ||
                      field.getValueType() == DcRepository.ValueTypes._DCOBJECTREFERENCE) {
 
                      reference = DcModules.get(field.getReferenceIdx());
                      main = field.getValueType() == DcRepository.ValueTypes._DCOBJECTREFERENCE ? module :
                             DcModules.get(DcModules.getMappingModIdx(module.getIndex(), reference.getIndex(), field.getIndex()));
 
                      if (    field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION ||
                              field.getFieldType() == ComponentFactory._REFERENCEFIELD) {
                         
                          columns.append("subselect");
                          columns.append(fieldCounter);
                          columns.append(".ID AS ");
                          columns.append("ID");
                          columns.append(fieldCounter);
                          columns.append(", ");
                         
                          columns.append("subselect");
                          columns.append(fieldCounter);
                          columns.append(".name AS ");
                          columns.append("NAME");
                          columns.append(fieldCounter);
                          columns.append(", ");
                         
                          columns.append("subselect");
                          columns.append(fieldCounter);                           
                          columns.append(".icon AS ");
                          columns.append("ICON");
                          columns.append(fieldCounter);
                             
                          if (field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION) {
                              joins.append(" left outer join ");
                              joins.append("(select ");
                              joins.append(reference.getTableName());
                              joins.append(".ID as ID,");
                              joins.append(main.getTableName());
                              joins.append(".");
                              joins.append(main.getField(DcMapping._A_PARENT_ID).getDatabaseFieldName());
                              joins.append(" as parentID, ");
                              joins.append(reference.getTableName());
                              joins.append(".");
                              joins.append(reference.getField(reference.getSystemDisplayFieldIdx()).getDatabaseFieldName());
                              joins.append(" as name,");
                             
                              if (reference.getType() == DcModule._TYPE_PROPERTY_MODULE) {
                                  joins.append(reference.getTableName());
                                  joins.append(".");
                                  joins.append(reference.getField(DcProperty._B_ICON).getDatabaseFieldName());
                              } else {
                                  joins.append("NULL");
                              }
                             
                              joins.append(" as icon");
                              joins.append(" from ");
                              joins.append(reference.getTableName());
                              joins.append(" inner join ");
                              joins.append(main.getTableName());
                              joins.append(" on ");
                              joins.append(reference.getTableName());
                              joins.append(".ID = ");
                              joins.append(main.getTableName());
                              joins.append(".");
                              joins.append(main.getField(DcMapping._B_REFERENCED_ID).getDatabaseFieldName());
                              joins.append(") subselect");
                              joins.append(fieldCounter);
                              joins.append(" on ");
                              joins.append(" subselect");
                              joins.append(fieldCounter);
View Full Code Here

       
        if (!DcSwingUtilities.displayQuestion("msgDeleteModuleConfirmation"))
            return;
       
        XmlModule xmlModule = (XmlModule) getCurrent().apply();
        DcModule module = DcModules.get(xmlModule.getIndex()) == null ?
                          DcModules.getPropertyBaseModule(xmlModule.getIndex()) :
                          DcModules.get(xmlModule.getIndex());
                         
        try {
            module.delete();

            // update the referencing modules; remove fields holding a reference to this module
            Collection<XmlField> remove = new ArrayList<XmlField>();
            for (DcModule reference : DcModules.getReferencingModules(xmlModule.getIndex())) {
                if (reference != null && reference.getXmlModule() != null) {
                    for (XmlField field : reference.getXmlModule().getFields()){
                        if (reference.getField(field.getIndex()).getSourceModuleIdx() == xmlModule.getIndex())
                            remove.add(field);
                    }
                    reference.getXmlModule().getFields().removeAll(remove);
                    new ModuleJar(reference.getXmlModule()).save();
                }
            }
           
            // parent child relation should be undone
            undoParentChildRelation(module.getParent() != null ? module.getParent() : module.getChild());
           
            // make sure the 'hasDependingModules' property is corrected for modules holding
            // a referencing to this module
            for (DcField field : module.getFields()) {
                if (field.getValueType() == DcRepository.ValueTypes._DCOBJECTREFERENCE) {
                    DcModule reference = DcModules.getReferencedModule(field);
                   
                    if (reference.getXmlModule() == null) continue;

                    if (reference.hasDependingModules() && DcModules.getReferencingModules(reference.getIndex()).size() == 1)
                        reference.getXmlModule().setHasDependingModules(false);
                   
                    new ModuleJar(reference.getXmlModule()).save();
                }
            }
           
            // not needed for property base modules
            if (DcModules.get(xmlModule.getIndex()) != null) {
View Full Code Here

        super();
       
        setTitle(DcResources.getText("lblViewSettings"));
        setHelpIndex("dc.settings.tableview");

        DcModule module = DcModules.getCurrent();
       
        fspParent = new FieldSelectionPanel(module, true, true, true);
        fspParent.setSelectedFields((int[]) module.getSetting(DcRepository.ModuleSettings.stTableColumnOrder));
        if (module.getChild() != null) {
            fspChild = new FieldSelectionPanel(module.getChild(), true, true, true);
            fspChild.setSelectedFields((int[]) module.getChild().getSetting(DcRepository.ModuleSettings.stTableColumnOrder));
        }
       
        build();
        pack();
       
        setSize(module.getSettings().getDimension(DcRepository.ModuleSettings.stTableViewSettingsDialogSize));
        setCenteredLocation();
    }
View Full Code Here

          ResultSetMetaData md = rs.getMetaData();
         
          int fieldStart = 1;
            int[] fields = null;
            DcObject dco;
            DcModule module = null;
            while (rs.next()) {
              try {
                int moduleIdx = rs.getInt("MODULEIDX");
              module = DcModules.get(moduleIdx);
              fieldStart = 2;
              } catch (Exception e) {
                module = DcModules.get(md.getTableName(1));
              }
             
              if (fields == null) {
                  fields = new int[md.getColumnCount() - (fieldStart - 1)];
                  int fieldIdx = 0;
                  for (int i = fieldStart; i < fields.length + fieldStart; i++) {
                    String column = md.getColumnName(i);
                      fields[fieldIdx++] = module.getField(column).getIndex();
                  }
              }
             
              dco = module.getItem();
                setValues(rs, dco, fields, requestedFields);

                objects.add(dco);
            }
        } catch (Exception e) {
View Full Code Here

        ResultSet rs = null;    
        String sql = null;
       
        try {
       
          DcModule module = DcModules.get(DcModules._CONTAINER);
         
          DataFilter df = DataFilters.getCurrent(DcModules._CONTAINER);
          sql = df.toSQL(new int[] {Container._ID, Container._A_NAME, Container._F_PARENT, Container._E_ICON}, true, false);
         
          conn = DatabaseManager.getConnection();
          stmt = conn.createStatement();
         
          logger.debug(sql);
          rs = stmt.executeQuery(sql);
         
          String name;
          String id;
          String parentId;
          String icon;
         
          Map<String, DcImageIcon> icons = new HashMap<String, DcImageIcon>();
          Map<String, String> parents = new LinkedHashMap<String, String>();
          Map<String, String> all = new LinkedHashMap<String, String>();
          Map<String, Collection<String>> relations = new HashMap<String, Collection<String>>();
         
         
          Settings settings = DcModules.get(DcModules._CONTAINER).getSettings();
          boolean flatView = settings.getBoolean(DcRepository.ModuleSettings.stContainerTreePanelFlat);
         
          while (rs.next()) {
            id = rs.getString(module.getField(Container._ID).getDatabaseFieldName());
            name = rs.getString(module.getField(Container._A_NAME).getDatabaseFieldName());
            parentId = rs.getString(module.getField(Container._F_PARENT).getDatabaseFieldName());
            icon = rs.getString(module.getField(Container._E_ICON).getDatabaseFieldName());
           
            if (parentId != null && !flatView) {
              Collection<String> children = relations.get(parentId);
              children = children == null ? new ArrayList<String>() : children;
              children.add(id);
              relations.put(parentId, children);
            } else {
              parents.put(id, name)
            }
           
            if (icon != null) icons.put(id, Utilities.base64ToImage(icon));
            all.put(id, name);
          }
         
          DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
          int counter = 0;
          for (String parentKey : parents.keySet()) {
           
            if (stop) break;
           
            ContainerNodeElement ne = new ContainerNodeElement(parentKey, (String) parents.get(parentKey), icons.get(parentKey));
            DcDefaultMutableTreeNode current = new DcDefaultMutableTreeNode(ne);
            model.insertNodeInto(current, top, counter++);
            top.addItem(parentKey, Integer.valueOf(module.getIndex()));
            createChildren(model, parentKey, current, relations, all, icons);
          }
         
        } catch (Exception e) {
          logger.error("Error while building the container tree", e);
View Full Code Here

            new ModuleJar(module).save();
           
            for (XmlField field : module.getFields()) {
               
                if (field.getModuleReference() !=  0 && field.getModuleReference() != module.getIndex()) {
                    DcModule m = DcModules.get(field.getModuleReference()) == null ?
                                 DcModules.get(field.getModuleReference() + module.getIndex()) :
                                 DcModules.get(field.getModuleReference());
                   
                    if (m != null && m.getXmlModule() != null)
                        new ModuleJar(m.getXmlModule()).save();
                }
            }
           
            module.setServingMultipleModules(true);

            DcModule result = DcModules.convert(module);
            DcModules.register(result);
            DcModules.registerPropertyModules(result);

            Settings settings = result.getSettings();
            DcFieldDefinitions definitions = (DcFieldDefinitions) settings.getDefinitions(DcRepository.ModuleSettings.stFieldDefinitions);
            DcFieldDefinition definition;
            for (XmlField field : module.getFields()) {
                definition = definitions.get(field.getIndex());
               
View Full Code Here

    }
   
    private Collection<DcField> getDefaultFields() {
        XmlModule xmlModule = getModule();

        DcModule module = null;
        if (xmlModule.getModuleClass() != null) {
            if (xmlModule.getModuleClass().equals(DcMediaModule.class))
                module = new DcMediaModule(10, false, "", "", "", "", "", "");
            else if (xmlModule.getModuleClass().equals(DcPropertyModule.class))
                module = new DcPropertyModule(10, "", "", "", "", "");
            else if (xmlModule.getModuleClass().equals(DcAssociateModule.class))
                module = new DcAssociateModule(10, "", "", "", "", "", "");
        }
       
        return module != null ? module.getFields() : new ArrayList<DcField>();
    }
View Full Code Here

       
        return table;
    }
   
    private String getChildTable(DcObject dco) {
        DcModule module = dco.getModule().getChild();
       
        QuickViewFieldDefinitions definitions =
            (QuickViewFieldDefinitions) module.getSettings().getDefinitions(DcRepository.ModuleSettings.stQuickViewFieldDefinitions);
       
        if (!module.isAbstract()) {
            Collection<Integer> additional = new ArrayList<Integer>();
            for (QuickViewFieldDefinition definition : definitions.getDefinitions())
                if (definition.isEnabled())
                    additional.add(definition.getField());
           
            dco.loadChildren(module.getMinimalFields(additional));
        } else {
            dco.loadChildren(new int[] {DcObject._ID});
        }
       
        Collection<DcObject> children = dco.getChildren();
       
        if (children == null || children.size() == 0)
            return "";
       
        String table = "<br><h3>" + module.getObjectNamePlural() + "</h3>";
       
        table += "<table " + Utilities.getHtmlStyle(DcSettings.getColor(DcRepository.Settings.stQuickViewBackgroundColor)) + ">\n";
       
        boolean first;
        StringBuffer description;
        String value;

        for (DcObject child : children) {
           
            if (module.isAbstract())
                child.load(new int[] {DcObject._ID, child.getModule().getDisplayFieldIdx()});
           
            table += "<tr><td>";

            first = true;
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.