Package net.datacrow.core.objects

Examples of net.datacrow.core.objects.DcObject


            logger.info(sql);
           
            DcModule mappingMod = DcModules.get(DcModules.getMappingModIdx(
                    moduleIdx, refMod.getIndex(), DcModules.get(moduleIdx).getField(columnName).getIndex()));
       
            DcObject mapping = mappingMod.getItem();
            while (rs.next()) {
                String ID = rs.getString(1);
                String referenceID = rs.getString(2);
                mapping.setValue(DcMapping._A_PARENT_ID, ID);
                mapping.setValue(DcMapping._B_REFERENCED_ID, referenceID);
                new InsertQuery(mapping).run();
            }
            rs.close();
        } catch (Exception e) {
            logger.error("Failed to create reference. Conversion has failed. Restart Data Crow to try again.", e);
View Full Code Here


           
            while (rs.next()) {
                String name = rs.getString(1);
               
                // check if the referenced item exists
                DcObject reference = refMod.getItem();
                reference.setValue(DcProperty._A_NAME, name);
                List<DcObject> items = new SelectQuery(new DataFilter(reference), null, new int[] {DcObject._ID}).run();
                if (items.size() == 0) {
                    reference.setIDs();
                    new InsertQuery(reference).run();
                }
               
                String sql2 = "select item.ID, property.ID from " + refMod.getTableName() + " property " +
                               "inner join " + DcModules.get(getModuleIdx()).getTableName() + " item " +
                               "on CONVERT(property." + refMod.getField(DcProperty._A_NAME).getDatabaseFieldName() + ",LONGVARCHAR) =" +
                               "CONVERT(item." + columnName + ",LONGVARCHAR) and item." + columnName + " = '" + name.replaceAll("'", "''") + "'";
                ResultSet rs2 = DatabaseManager.executeSQL(sql2);
               
                while (rs2.next()) {
                    String itemID = rs2.getString(1);
                    String propertyID = rs2.getString(2);
                   
                    if (getNewFieldType() == ComponentFactory._REFERENCESFIELD) {
                        DcModule mappingMod = DcModules.get(DcModules.getMappingModIdx(
                                moduleIdx, refMod.getIndex(), DcModules.get(moduleIdx).getField(columnName).getIndex()));
                       
                        DcObject mapping = mappingMod.getItem();
                        mapping.setValue(DcMapping._A_PARENT_ID, itemID);
                        mapping.setValue(DcMapping._B_REFERENCED_ID, propertyID);
                       
                        items = new SelectQuery(mapping, null).run();
                        if (items.size() == 0)
                            new InsertQuery(mapping).run();
                       
View Full Code Here

        return true;
    }   

    @Override
    public DcObject parse(String filename, int directoryUsage) {
        DcObject movie = DcModules.get(DcModules._MOVIE).getItem();

        movie.setValue(Movie._SYS_FILENAME, filename);
        movie.setValue(Movie._A_TITLE, getName(filename, directoryUsage));

        try {
            Hash.getInstance().calculateHash(movie);

            FilePropertiesMovie fpm = new FilePropertiesMovie(filename);
            Long playlength = Long.valueOf(fpm.getDuration());
            if (playlength.intValue() <= 0 && fpm.getVideoWidth() <= 0)
                return movie;

            if (directoryUsage != 1 && fpm.getName() != null && fpm.getName().trim().length() > 0)
                movie.setValue(Movie._A_TITLE, fpm.getName());
           
            DataManager.createReference(movie, Movie._D_LANGUAGE, fpm.getLanguage());
           
           
            long frames = (long) (fpm.getDuration() * fpm.getVideoRate());
            movie.setValue(Movie._L_PLAYLENGTH, playlength);
            movie.setValue(Movie._N_VIDEOCODEC, fpm.getVideoCodec());
            movie.setValue(Movie._O_AUDIOCODEC, fpm.getAudioCodec());
            movie.setValue(Movie._P_WIDTH, fpm.getVideoWidth() <= 0 ? null : Long.valueOf(fpm.getVideoWidth()));
            movie.setValue(Movie._Q_HEIGHT, fpm.getVideoHeight() <= 0 ? null : Long.valueOf(fpm.getVideoHeight()));
            movie.setValue(Movie._R_FPS, fpm.getVideoRate() <= 0 ? null : Double.valueOf(fpm.getVideoRate()));
            movie.setValue(Movie._S_FRAMES, frames <= 0 ? null : frames);
            movie.setValue(Movie._T_AUDIOBITRATE, fpm.getAudioBitRate() <= 0 ? null : Long.valueOf(fpm.getAudioBitRate()));
            movie.setValue(Movie._U_AUDIOSAMPLINGRATE, fpm.getAudioRate() <= 0 ? null : Long.valueOf(fpm.getAudioRate()));
            movie.setValue(Movie._V_AUDIOCHANNEL, fpm.getAudioChannels() <= 0 ? null : Long.valueOf(fpm.getAudioChannels()));
           
            DataManager.createReference(movie, Movie._2_SUBTITLELANGUAGE, fpm.getSubtitles());
           
            setImages(filename, movie, Movie._X_PICTUREFRONT, Movie._Y_PICTUREBACK, Movie._Z_PICTURECD);
           
            int bitrate = fpm.getVideoBitRate();
            if (bitrate <= 0) {
                MovieFile mf = new MovieFile(filename);
                bitrate = (int) mf.getVideoBitrate();
            }

            movie.setValue(Movie._W_VIDEOBITRATE, bitrate <= 0 ? null :  Long.valueOf(bitrate));

        } catch (Exception exp) {
            getClient().addMessage(DcResources.getText("msgCouldNotReadInfoFrom", filename));
        }
       
View Full Code Here

    }
  }
 
  private void add() {
    DcModule module = DcModules.get(moduleIdx);
    DcObject dco = module.getItem();
    if (module.isChildModule()) {
        String parentID;
      if (DcSwingUtilities.getRootFrame() instanceof ItemForm)
        parentID = ((ItemForm) DcSwingUtilities.getRootFrame()).getItem().getID();
      else
        parentID = module.getParent().getCurrentSearchView().getSelectedItem().getID();
     
      dco.setValue(dco.getParentReferenceFieldIndex(), parentID);
     
      if (dco.getModule().getIndex() == DcModules._AUDIOTRACK)
        dco.setValue(AudioTrack._F_TRACKNUMBER, Long.valueOf(table.getRowCount() + 1));
      else if (dco.getModule().getIndex() == DcModules._MUSICTRACK)
        dco.setValue(AudioTrack._F_TRACKNUMBER, Long.valueOf(table.getRowCount() + 1));
    }
    table.add(dco);
  }
View Full Code Here

 
  private class SavingTask extends Thread {
    @Override
    public void run() {
      for (int row = table.getRowCount(); row > 0; row--) {
        DcObject dco = table.getItemAt(row - 1);
        dco.setIDs();
       
        try {
          dco.saveNew(false);
          table.removeRow(row - 1);
        } catch (ValidationException e) {
              DcSwingUtilities.displayWarningMessage(e.getMessage());
        }
      }
View Full Code Here

   
    private void initialize() {
        user.loadChildren(null);

        for (RegisteredPlugin plugin : Plugins.getInstance().getRegistered()) {
            DcObject permission = null;
           
            if (!plugin.isAuthorizable())
                continue;
           
            for (DcObject child : user.getChildren()) {
                Permission p = (Permission) child;
                if (p.getPlugin() != null &&  plugin.getKey().equals(p.getPlugin())) {
                    permission = p;
                    break;
                }
            }
           
            if (permission == null) {
                permission = DcModules.get(DcModules._PERMISSION).getItem();
                permission.setIDs();
                permission.setValue(Permission._A_PLUGIN, plugin.getKey());
               
                if (update) {
                    try {
                        // create the missing permission
                        permission.saveNew(false);
                    } catch (ValidationException ve) {
                        logger.error(ve, ve);
                    }
                }
            }
           
            Object[] row = new Object[] {plugin.getKey(),
                                         permission.getValue(Permission._D_VIEW),
                                         permission};
            table.addRow(row);
            permission.markAsUnchanged();
        }
    }
View Full Code Here

           ,GridBagConstraints.NORTH, GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5), 0, 0));
    }
   
    public void open() {
        DcObject dco = list.getSelectedItem();
        if (dco != null) {
            dco.markAsUnchanged();
            DcMinimalisticItemForm itemForm = new DcMinimalisticItemForm(false, true, dco, this);
            itemForm.setVisible(true);
        }
    }
View Full Code Here

            setBackground(list.getBackground());
            setForeground(list.getForeground());
        }

        if (value instanceof DcObject) {
            DcObject o = (DcObject) value;
            setIcon(o.getIcon());
            setText(o.toString());
        } else if (value instanceof DcModule) {
          DcModule module = (DcModule) value;
            setIcon(module.getIcon16());
            setText(module.getLabel());
        } else if (value instanceof String) {
View Full Code Here

        buildPanel(loan.isAvailable(dco.getID()));
        setLoanInformation(loan);
    }
   
    private String getPersonLink(String personID) {
        DcObject person = DataManager.getItem(DcModules._CONTACTPERSON, personID);
        return person != null ? descriptionPane.createLink(person, person.toString()) : "";
    }
View Full Code Here

        panelLend.setVisible(true);
        panelReturn.setVisible(false);
       
        if (objects.size() == 1) {
            tableLoans.clear();
            DcObject dco = objects.get(0);
            for (Loan loan : DataManager.getLoans(dco.getID())) {
                if (loan.getValue(Loan._B_ENDDATE) != null)
                    tableLoans.add(loan, true);
            }
        }
    }
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.