Package net.datacrow.core.modules

Examples of net.datacrow.core.modules.DcModule


    private static DcField getField(String s) {
        try {
            int mod = Integer.parseInt(s.substring(0, s.indexOf("/&/")));
            String columnName = s.substring(s.indexOf("/&/") + 3, s.length());
           
            DcModule module = DcModules.get(mod);
            for (DcField field : module.getFields()) {
                if (field.getDatabaseFieldName().equalsIgnoreCase(columnName))
                    return field;
            }
        } catch (Exception exp) {
            logger.error("Could not find valid field information in " + s);
View Full Code Here


   
    @Override
    public Object apply(DcField field, Object value) {
        Object result = value;
       
        DcModule module = DcModules.get(field.getModule());
        int counter = 0;
       
        try {
            if (!fillGaps) {
                String query = "SELECT MAX(" + field.getDatabaseFieldName() + ") AS COUNTMAXIMUM FROM " +
                               module.getTableName();
                ResultSet rs = DatabaseManager.executeSQL(query);
                int maximum = 0;
                while (rs.next()) {
                    maximum = rs.getInt("COUNTMAXIMUM");
                }
               
                result = Long.valueOf(maximum + getStep());
                rs.close();
            } else {
                counter = counter + getStep();
               
                String qryCurrent = "SELECT " + field.getDatabaseFieldName() + " FROM " + module.getTableName() +
                " WHERE " + field.getDatabaseFieldName() + " IS NOT NULL AND " +
                field.getDatabaseFieldName() + " > 0 " +
                "ORDER BY 1";           
               
                Collection<Integer> currentValues = new ArrayList<Integer>();
View Full Code Here

   
    public ViewPopupMenu(DcObject dco, int viewType, int viewIdx) {
       
        this.dco = dco;
       
        DcModule current = DcModules.getCurrent();
       
        DcModule module = dco.getModule();
        if (viewType == View._TYPE_SEARCH &&
            !module.isChildModule() &&
            !(current.getIndex() == DcModules._CONTAINER &&
              dco.getModule().getIndex() != DcModules._CONTAINER)) {

            if (module.isAbstract())
                PluginHelper.add(this, "SaveSelected");
           
            PluginHelper.add(this, "OpenItem");
           
            if (module.getIndex() != DcModules._USER)
                PluginHelper.add(this, "EditAsNew", null, dco, null, -1, module.getIndex());
        }
       
        String filename = dco.getFilename();
        File file = !Utilities.isEmpty(filename) ? new File(filename) : null;
       
        if (viewType == View._TYPE_SEARCH) {
            if (dco.getModule().getParent() != null) {
                // in case a child is selected, make sure its the child which is going to be deleted
                // and not the parent (via the DcModules.getCurrent(), which returns the parent).
                PluginHelper.add(this, "Delete", module.getIndex());
            } else if ((current.getIndex() == DcModules._CONTAINER && dco.getModule().getIndex() != DcModules._CONTAINER)) {
                PluginHelper.add(this, "Delete", DcModules._ITEM);               
            } else {
                // make sure the actual SELECTED module is used for deleting the item. otherwise, if
                // the media module is selected, the item from the, for example, software module view
                // is deleted.
                PluginHelper.add(this, "Delete", DcModules.getCurrent().getIndex());
            }
           
            if (file != null && SecurityCentre.getInstance().getUser().isAdmin() && dco.getModule().isFileBacked()) {
               
                JMenu menuFile = ComponentFactory.getMenu(IconLibrary._icoDriveManager, DcResources.getText("lblFile"));
               
                JMenuItem miDelete = ComponentFactory.getMenuItem(IconLibrary._icoDelete, DcResources.getText("lblDeleteFile"));
                miDelete.addActionListener(this);
                miDelete.setActionCommand("deleteFile");
                miDelete.setEnabled(file.exists());

                JMenuItem miMove = ComponentFactory.getMenuItem(DcResources.getText("lblMoveFile"));
                miMove.addActionListener(this);
                miMove.setActionCommand("moveFile");
                miMove.setEnabled(file.exists());

                JMenuItem miLocateHP = ComponentFactory.getMenuItem(IconLibrary._icoDriveScanner, DcResources.getText("lblLocateFile", DcResources.getText("lblMatchOnHashAndSize")));
                miLocateHP.addActionListener(this);
                miLocateHP.setActionCommand("locateFileHP");
                miLocateHP.setEnabled(!file.exists() && dco.isFilled(DcObject._SYS_FILEHASH) && dco.isFilled(DcObject._SYS_FILESIZE));
               
                JMenuItem miLocateMP = ComponentFactory.getMenuItem(IconLibrary._icoDriveScanner, DcResources.getText("lblLocateFile", DcResources.getText("lblMatchOnFilenameAndSize")));
                miLocateMP.addActionListener(this);
                miLocateMP.setActionCommand("locateFileMP");
                miLocateMP.setEnabled(!file.exists() && dco.isFilled(DcObject._SYS_FILESIZE));           

                JMenuItem miLocateLP = ComponentFactory.getMenuItem(IconLibrary._icoDriveScanner, DcResources.getText("lblLocateFile", DcResources.getText("lblMatchOnFilename")));
                miLocateLP.addActionListener(this);
                miLocateLP.setActionCommand("locateFileLP");
                miLocateLP.setEnabled(!file.exists());       
               
                menuFile.add(miDelete);
                menuFile.add(miMove);
                menuFile.add(miLocateHP);
                menuFile.add(miLocateMP);
                menuFile.add(miLocateLP);
               
                addSeparator();
                add(menuFile);
            }           
           
        } else {
            PluginHelper.add(this, "RemoveRow", DcModules.getCurrent().getIndex());
            PluginHelper.add(this, "AddRow", DcModules.getCurrent().getIndex());
        }  
       
        if (viewType == View._TYPE_SEARCH &&
            module.getIndex() == DcModules._USER &&
            SecurityCentre.getInstance().getUser().isAuthorized("SetPassword")) {

            addSeparator();
            PluginHelper.add(this, "SetPassword", "", dco, null, viewType, DcModules.getCurrent().getIndex());
        }

        if (!DcModules.getCurrent().isAbstract()) {
            addSeparator();
            PluginHelper.add(this, "ItemExporterWizard", "", dco, null, viewIdx, dco.getModule().getIndex());
        }
       
        if (viewType == View._TYPE_SEARCH && DcModules.getCurrent().hasReports()) {
            PluginHelper.add(this, "Report", "", dco, null, viewIdx, DcModules.getCurrent().getIndex());
        }
       
        addSeparator();
        PluginHelper.add(this, "Sort");
       
        if viewType == View._TYPE_SEARCH &&
            module.canBeLend() &&
            SecurityCentre.getInstance().getUser().isAuthorized("Loan")) {
         
            addSeparator();
            PluginHelper.add(this, "Loan");
        }

        addSeparator();

        JMenu menuAdmin = ComponentFactory.getMenu(IconLibrary._icoModuleTypeProperty16, DcResources.getText("lblAdministration"));
       
        Collection<DcPropertyModule> modules = new ArrayList<DcPropertyModule>();
        for (DcFieldDefinition definition : module.getFieldDefinitions().getDefinitions()) {
            DcField field = module.getField(definition.getIndex());
            DcPropertyModule pm = DcModules.getPropertyModule(field);
           
            if (pm != null && !modules.contains(pm))
                modules.add(pm);
        }

        for (DcModule pm : modules) {
            try {
                Plugin plugin = Plugins.getInstance().get("ManageItem", dco, null, viewIdx,  pm.getIndex());
                if (    plugin != null &&SecurityCentre.getInstance().getUser().isAuthorized(plugin) &&
                        UserMode.isCorrectXpLevel(plugin.getXpLevel())) {
                   
                    JMenuItem item = ComponentFactory.getMenuItem(plugin);
                    item.setEnabled(plugin.isEnabled());
                    item.setIcon(plugin.getIcon());
                   
                    menuAdmin.add(item);
                }
            } catch (InvalidPluginException e) {
                logger.error(e, e);
            }
        }
       
        if (menuAdmin.getItemCount() > 0)
            add(menuAdmin);
       
        addSeparator();
        PluginHelper.add(this, "ViewSettings");
       
        if (viewType == View._TYPE_SEARCH) {
            FileImporter importer = module.getImporter();
            if (importer != null && importer.allowReparsing() && module.getFileField() != null) {
                addSeparator();
                PluginHelper.add(this, "AttachFileInfo");
            }
        }
       
        addSeparator();
       
        if (current.getIndex() != DcModules._ITEM) {
            PluginHelper.add(this, "UpdateAll", module.getIndex());
            PluginHelper.add(this, "FindReplace", module.getIndex());
        }
       
        if (file != null && dco.getModule().isFileBacked())
            PluginHelper.add(this, "FileLauncher", module.getIndex());
       
        Collection<Plugin> plugins = Plugins.getInstance().getUserPlugins(dco, viewType, module.getIndex());
        for (Plugin plugin : plugins) {
            if (plugin.isShowInPopupMenu()) {
                addSeparator();
                add(ComponentFactory.getMenuItem(plugin));
            }
View Full Code Here

        List<DcReference> references = new ArrayList<DcReference>();
        if (getDcField().getFieldType() == ComponentFactory._RATINGCOMBOBOX) {
            for (int rating = -1; rating < 11; rating++)
                references.add(new DcReference(Rating.getLabel(rating), String.valueOf(rating)));
        } else {
            DcModule module = DcModules.getReferencedModule(getDcField());
            for (DcSimpleValue value : DataManager.getSimpleValues(module.getIndex(), false))
                references.add(new DcReference(value.getName(), value.getID()));
        }
        return references;
    }
View Full Code Here

            df = new DataFilter(moduleIdx);
           
            setFields(moduleIdx);
            modules.add(new DcWebModule(moduleIdx, DcModules.get(moduleIdx).getLabel()));
           
            DcModule child = DcModules.get(moduleIdx).getChild();
            if (child != null) {
                modules.add(new DcWebModule(child.getIndex(), DcModules.get(child.getIndex()).getLabel()));
                setFields(child.getIndex());
            }
        }
       
        setFieldIdx(fields.get(moduleIdx).get(0).getIndex(), moduleIdx);
    }
View Full Code Here

        if (tab == 4 && !isPictureTabVisible())
            tab = 0;
    }

    public void loadChildren() {
        DcModule childModule = DcModules.get(getModule()).getChild();
       
        List<List<?>> woChildren = new ArrayList<List<?>>();
        List<DcWebField> woFields = new ArrayList<DcWebField>();
        getDcObject().setChildren(new ArrayList<DcObject>());
        getDcObject().loadChildren(null);
        if (getDcObject().getModule().getChild() != null) {
            for (DcObject child : getDcObject().getChildren()) {
                List<Object> values = new ArrayList<Object>();

                for (WebFieldDefinition def : childModule.getWebFieldDefinitions().getDefinitions()) {
                    DcField field = child.getModule().getField(def.getField());
                    if (def.isOverview() && getUser().isAuthorized(field) && field.isEnabled()) {
                        String s = child.getDisplayString(field.getIndex());
                       
                        if (def.getMaxTextLength() != 0 && field.getValueType() != DcRepository.ValueTypes._PICTURE)
                            s = StringUtils.concatUserFriendly(s, def.getMaxTextLength());

                        values.add(s);
                    }
                }
                values.add(child.getID());
                woChildren.add(values);
            }
           
            for (WebFieldDefinition def : DcModules.get(DcModules.get(getModule()).getChild().getIndex()).getWebFieldDefinitions().getDefinitions()) {
                DcField field = childModule.getField(def.getField());
                if (def.isOverview() && getUser().isAuthorized(field) && field.isEnabled()) {
                    DcWebField wf = new DcWebField(field);
                    wf.setWidth(def.getWidth());
                    wf.setLinkToDetails(def.isLink());
                    wf.setMaxTextLength(def.getMaxTextLength());
View Full Code Here

                    module.getIndex() != DcModules._USER) {
               
                modules.add(new DcWebModule(module.getIndex(), module.getLabel()));
               
                for (DcField field : module.getFields()) {
                    DcModule referencedMod = DcModules.getReferencedModule(field);
                    if (    getUser().isAuthorized(module) &&
                            referencedMod.isEnabled() &&
                            referencedMod.getIndex() != module.getIndex() &&
                          !(referencedMod instanceof DcPropertyModule) &&
                            referencedMod.getIndex() != DcModules._CONTACTPERSON &&
                            referencedMod.getIndex() != DcModules._CONTAINER) {
                       
                        modules.add(new DcWebModule(referencedMod.getIndex(), referencedMod.getLabel()));
                    }
                }
            }
        }
    }
View Full Code Here

    public static void refresh() {
        templates.clear();
       
        for (DcModule module : DcModules.getAllModules()) {
            if (module.getTemplateModule() != null) {
                DcModule templateModule = module.getTemplateModule();

                try {
                  for (DcObject dco : DataManager.get(templateModule.getIndex(), null))
                    templates.add((DcTemplate) dco);
                } catch (Exception e) {
                    logger.error("Could not refresh the taemplate list for " + module, e);

                }
View Full Code Here

     * Sets the order. Results retrieved will be sorted based on this order.
     * @param s Array of field names (column names).
     */
    public void setOrder(String[] s) {
        order = new DcField[s.length];
        DcModule m = DcModules.get(module);
        for (int i = 0; i < s.length; i++)
            order[i] = m.getField(s[i]);
    }
View Full Code Here

     * @param fields
     * @param order
     * @return
     */
    public String toSQLFlatStructure(int[] fields) {
      DcModule module = DcModules.get(getModule());
      int[] queryFields = fields == null || fields.length == 0 ? module.getFieldIndices() : fields;
     
      StringBuffer sql = new StringBuffer();
      StringBuffer joins = new StringBuffer();
     
      sql.append("SELECT ");
      joins.append(" FROM ");
      joins.append(module.getTableName());
      joins.append(" MAINTABLE ");
     
      DcModule mapping;
      DcModule reference;
      String subTable;
      String mapTable;
      int tableCounter = 0;
      int columnCounter = 0;
     
      for (int idx : queryFields) {
        DcField field = module.getField(idx);
       
        if (columnCounter > 0)
          sql.append(", ");
       
        if (field.getValueType() == DcRepository.ValueTypes._DCOBJECTCOLLECTION) {
          mapping = DcModules.get(DcModules.getMappingModIdx(module.getIndex(), field.getReferenceIdx(), field.getIndex()));
          reference = DcModules.get(field.getReferenceIdx());
         
          mapTable = " MAPTABLE" + tableCounter;
         
          joins.append(" LEFT OUTER JOIN ");
          joins.append(mapping.getTableName());
          joins.append(mapTable);
          joins.append(" ON ");
          joins.append(mapTable);
          joins.append(".");
          joins.append(mapping.getField(DcMapping._A_PARENT_ID).getDatabaseFieldName());
          joins.append(" = MAINTABLE.ID");
         
          subTable = " SUBTABLE" + tableCounter;
          joins.append(" INNER JOIN ");
          joins.append(reference.getTableName());
          joins.append(subTable);
          joins.append(" ON ");
          joins.append(subTable);
          joins.append(".ID");
          joins.append(" = ");
          joins.append(mapTable);
          joins.append(".");
          joins.append(mapping.getField(DcMapping._B_REFERENCED_ID).getDatabaseFieldName());
         
          sql.append(subTable);
          sql.append(".");
          sql.append(reference.getField(reference.getDisplayFieldIdx()).getDatabaseFieldName());
          tableCounter++;
         
        } else if (field.getValueType() == DcRepository.ValueTypes._DCOBJECTREFERENCE) {
          reference = DcModules.get(field.getReferenceIdx());
          subTable = " SUBTABLE" + tableCounter;
          joins.append(" LEFT OUTER JOIN ");
          joins.append(reference.getTableName());
          joins.append(subTable);
          joins.append(" ON ");
          joins.append(subTable);
          joins.append(".ID = MAINTABLE.");
          joins.append(field.getDatabaseFieldName());
         
          sql.append(subTable);
          sql.append(".");
          sql.append(reference.getField(reference.getDisplayFieldIdx()).getDatabaseFieldName());
          tableCounter++;
         
        } else if (field.getValueType() == DcRepository.ValueTypes._PICTURE) {
          reference = DcModules.get(DcModules._PICTURE);
          subTable = " SUBTABLE" + tableCounter;
         
          sql.append("(case when ");
          sql.append(subTable);
          sql.append(".OBJECTID IS NULL then '' else ");
          sql.append("'/mediaimages/'+MAINTABLE.ID+'_");
          sql.append(field.getDatabaseFieldName());
          sql.append("_small.jpg' ");
          sql.append("END) AS ");
          sql.append(field.getDatabaseFieldName());
         
          joins.append(" LEFT OUTER JOIN ");
          joins.append(reference.getTableName());
          joins.append(subTable);
          joins.append(" ON ");
          joins.append(subTable);
          joins.append(".OBJECTID = MAINTABLE.ID");
          joins.append(" AND ");
          joins.append(subTable);
          joins.append(".");
          joins.append(reference.getField(Picture._B_FIELD));
          joins.append("='");
          joins.append(field.getDatabaseFieldName());
          joins.append("'");

        } else if (field.getIndex() == DcObject._SYS_AVAILABLE ||
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.