Package net.datacrow.core.objects

Examples of net.datacrow.core.objects.DcObject


     * @param isExisting Indicates if the check is performed for a new or an existing item.
     */
    public static boolean isUnique(DcObject o, boolean isExisting) {
        if (o.hasPrimaryKey() && !o.getModule().isChildModule()) {
            boolean hasUniqueFields = false;
            DcObject dco = o.getModule().getItem();

            for (DcFieldDefinition def : o.getModule().getFieldDefinitions().getDefinitions()) {
                if (def.isUnique()) {
                    dco.setValue(def.getIndex(), o.getValue(def.getIndex()));
                    hasUniqueFields = true;
                }
            }
               
            if (hasUniqueFields) {
View Full Code Here


        return false;
    }   
   
    @Override
    public DcObject parse(String filename, int directoryUsage) {
        DcObject image = DcModules.get(DcModules._IMAGE).getItem();
       
        try {
            image.setIDs();
            image.setValue(Image._A_TITLE, getName(filename, directoryUsage));
            image.setValue(Image._SYS_FILENAME, filename);
           
            Picture pic = (Picture) DcModules.get(DcModules._PICTURE).getItem();
            DcImageIcon icon;
            if (filename.toLowerCase().endsWith(".svg")) {
                SVGtoBufferedImageConverter converter = new SVGtoBufferedImageConverter();
                BufferedImage bi = converter.renderSVG(filename);
                icon = new DcImageIcon(Utilities.getScaledImage(new DcImageIcon(bi), 400, 400));
                filename = File.createTempFile(String.valueOf(Utilities.getUniqueID()), ".png").toString();
                icon.setFilename(filename);
                icon.save();
                bi.flush();
            } else {
                icon = new DcImageIcon(Utilities.getScaledImage(new DcImageIcon(filename), 400, 400));
                pic.setValue(Picture._G_EXTERNAL_FILENAME, filename);
            }
           
            int width = icon.getIconWidth();
            int height = icon.getIconHeight();
           
            image.setValue(Image._F_WIDTH, width != -1 ? Long.valueOf(width) : null);
            image.setValue(Image._G_HEIGHT, height != -1 ? Long.valueOf(height) : null);
           
            icon.getImage().flush();
           
            pic.setValue(Picture._A_OBJECTID, image.getID());
            pic.setValue(Picture._B_FIELD, image.getField(Image._I_IMAGE).getDatabaseFieldName());
            pic.setValue(Picture._D_IMAGE, icon);
            pic.isEdited(true);
           
            image.setValue(Image._I_IMAGE, pic);
           
            File jpegFile = new File(filename);
           
            try {
                Metadata metadata = JpegMetadataReader.readMetadata(jpegFile);
                if (metadata.containsDirectory(ExifDirectory.class)) {
                    Directory exifDirectory = metadata.getDirectory(ExifDirectory.class);
                   
                    try {
                        String camera = exifDirectory.getString(ExifDirectory.TAG_MODEL);
                        image.setValue(Image._Q_CAMERA, camera);
                    } catch (Exception me) {}

                    try {
                        int compression = exifDirectory.getInt(ExifDirectory.TAG_COMPRESSION);
                        image.setValue(Image._O_COMPRESSION, Long.valueOf(compression));
                    } catch (Exception me) {}


                    try {
                        String description = exifDirectory.getString(ExifDirectory.TAG_IMAGE_DESCRIPTION);
                        image.setValue(Image._B_DESCRIPTION, description);
                    } catch (Exception me) {}

                    try {
                        Date date = exifDirectory.getDate(ExifDirectory.TAG_DATETIME);
                        if (date != null) {
                            cal.setTime(date);
                            cal.set(Calendar.HOUR_OF_DAY, 0);
                            cal.set(Calendar.MINUTE, 0);
                            cal.set(Calendar.SECOND, 0);
                            image.setValue(Image._N_DATE, cal.getTime());
                        }
                    } catch (Exception me) {}
                }
               
                if (metadata.containsDirectory(IptcDirectory.class)) {
                    try {
                        Directory iptcDirectory = metadata.getDirectory(IptcDirectory.class);
                        String city = iptcDirectory.getString(IptcDirectory.TAG_CITY);
                        String country = iptcDirectory.getString(IptcDirectory.TAG_COUNTRY_OR_PRIMARY_LOCATION);
                        String state = iptcDirectory.getString(IptcDirectory.TAG_PROVINCE_OR_STATE);
                       
                        String location = "";
                        location += country != null ? country + ", " : "";
                        location += state != null ? state  + ", " : "";
                        location += city != null ? city : "";
                       
                        image.setValue(Image._P_PLACE, location);
                    } catch (Exception me) {}
                }
               
            } catch (JpegProcessingException jpe) {}
           
View Full Code Here

                                            hasFocus,
                                            row,
                                            column);       
       
        if (value != null) {
            DcObject o = null;
      if (value instanceof DcObject)
        o = (DcObject) value;
      //else
        //o = DataManager.getObjectForDisplayValue(field.getReferenceIdx(), value.toString());
           
            if (o != null) {
              setIcon(o.getIcon());
              setText(o.toString());
            } else {
                setIcon(null);
            }
           
            o = null;
View Full Code Here

        osf = null;
        os = null;
    }   
   
    private void applySettings() {
        DcObject dco = osf.getDcObject();
        if (dco != null) {
            IServer server = os.getServer(dco);
            if (server != null) {
                comboServers.setSelectedItem(server);
               
View Full Code Here

                } catch (Exception exp) {
                    logger.error(exp, exp);
                }
            } else {
                int module = Integer.valueOf(query.substring(query.indexOf("=") + 1));
                DcObject dco = DataManager.getItem(module, ID);
               
                if (dco != null) {
                    dco.markAsUnchanged();
                    new ItemForm(false, true, dco, false).setVisible(true);
                }
            }
        }
    }    
View Full Code Here

    }
   
    @Override
    public DcDefaultMutableTreeNode getFullPath(DcObject dco) {
        DcDefaultMutableTreeNode node;
        DcObject parent = (DcObject) dco.getValue(Container._F_PARENT);
        node = parent != null ?
                findNode(new DcDefaultMutableTreeNode(new ContainerNodeElement(parent.getID(), parent.toString(), null)), top, true) :
                new DcDefaultMutableTreeNode(DcModules.get(DcModules._CONTAINER).getLabel());
           
        node = node == null ? new DcDefaultMutableTreeNode(DcModules.get(DcModules._CONTAINER).getLabel()) : node;
        node.removeAllChildren();
        node.add(new DcDefaultMutableTreeNode(new ContainerNodeElement(dco.getID(), dco.toString(), dco.getIcon())));
View Full Code Here

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

        btCreate = null;
        removeAll();
    }
   
    private void create() {
        DcObject dco = DcModules.get(referenceIdx).getItem();
        ItemForm itemForm = new ItemForm(false, false, dco, true);
        itemForm.setListener(this);
        itemForm.setVisible(true);
    }
View Full Code Here

        fld.setCaretPosition(0);
    }
   
    @Override
    public void notifyItemSaved(DcObject dco) {
        DcObject mapping = DcModules.get(mappingModIdx).getItem();
        mapping.setValue(DcMapping._B_REFERENCED_ID, dco.getID());
        references.add(mapping);
        setDescription();
    }
View Full Code Here

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

        for (DcField field : module.getFields()) {
            DcObject permission = null;
           
            for (DcObject child : user.getChildren()) {
                Permission p = (Permission) child;
                if (p.getFieldIdx() == field.getIndex() && p.getModuleIdx() == module.getIndex()) {
                    permission = p;
                    break;
                }
            }
           
            if (permission == null) {
                permission = DcModules.get(DcModules._PERMISSION).getItem();
                permission.setIDs();
                permission.setValue(Permission._B_FIELD, Long.valueOf(field.getIndex()));
                permission.setValue(Permission._C_MODULE, Long.valueOf(field.getModule()));
                permission.setValue(Permission._D_VIEW, Boolean.TRUE);
                permission.setValue(Permission._E_EDIT, Boolean.FALSE);
               
                if (update) {
                    // create the missing permission
                    try {
                        permission.saveNew(false);
                    } catch (ValidationException ve) {
                        logger.error(ve, ve);
                    }
                }
            }
           
            Object[] row = new Object[] {DcModules.get(field.getModule()),
                                         field.getLabel(),
                                         permission.getValue(Permission._D_VIEW),
                                         permission.getValue(Permission._E_EDIT),
                                         permission};
            table.addRow(row);
            permission.markAsUnchanged();
        }
    }
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.