Search in sources :

Example 1 with FileAttributeDefinition

use of org.openforis.idm.metamodel.FileAttributeDefinition in project collect by openforis.

the class RecordFileBackupTask method calculateRecordFileEntryName.

public static String calculateRecordFileEntryName(FileAttribute fileAttribute) {
    FileAttributeDefinition fileAttributeDefinition = fileAttribute.getDefinition();
    String repositoryRelativePath = RecordFileManager.getRepositoryRelativePath(fileAttributeDefinition, ZIP_FOLDER_SEPARATOR, false);
    String filename = fileAttribute.getFilename();
    return StringUtils.join(Arrays.asList(UPLOADED_FILES_FOLDER, repositoryRelativePath, filename), ZIP_FOLDER_SEPARATOR);
}
Also used : FileAttributeDefinition(org.openforis.idm.metamodel.FileAttributeDefinition)

Example 2 with FileAttributeDefinition

use of org.openforis.idm.metamodel.FileAttributeDefinition in project collect by openforis.

the class FileAttributeDefinitionPR method onStartDefinition.

@Override
protected void onStartDefinition() throws XmlParseException, XmlPullParserException, IOException {
    super.onStartDefinition();
    String extensions = getAttribute(EXTENSIONS, false);
    Integer maxSize = getIntegerAttribute(MAX_SIZE, false);
    FileAttributeDefinition defn = (FileAttributeDefinition) getDefinition();
    defn.setMaxSize(maxSize);
    if (extensions != null) {
        String[] exts = extensions.split(" ");
        for (String ext : exts) {
            defn.addExtension(ext);
        }
    }
}
Also used : FileAttributeDefinition(org.openforis.idm.metamodel.FileAttributeDefinition)

Example 3 with FileAttributeDefinition

use of org.openforis.idm.metamodel.FileAttributeDefinition in project collect by openforis.

the class RecordFileManager method getRepositoryFileAbsolutePath.

public String getRepositoryFileAbsolutePath(FileAttribute fileAttribute) {
    FileAttributeDefinition defn = fileAttribute.getDefinition();
    String filename = fileAttribute.getFilename();
    if (StringUtils.isNotBlank(filename)) {
        String path = getRepositoryFileAbsolutePath(defn, filename);
        return path;
    } else {
        return null;
    }
}
Also used : FileAttributeDefinition(org.openforis.idm.metamodel.FileAttributeDefinition)

Example 4 with FileAttributeDefinition

use of org.openforis.idm.metamodel.FileAttributeDefinition in project collect by openforis.

the class RecordFileManager method getRepositoryFile.

public java.io.File getRepositoryFile(FileAttribute fileAttribute) {
    FileAttributeDefinition defn = fileAttribute.getDefinition();
    String filename = fileAttribute.getFilename();
    if (StringUtils.isNotBlank(filename)) {
        java.io.File file = getRepositoryFile(defn, filename);
        return file;
    } else {
        return null;
    }
}
Also used : FileAttributeDefinition(org.openforis.idm.metamodel.FileAttributeDefinition) File(java.io.File)

Example 5 with FileAttributeDefinition

use of org.openforis.idm.metamodel.FileAttributeDefinition in project collect by openforis.

the class NodeDefinitionProxy method fromList.

static List<NodeDefinitionProxy> fromList(EntityDefinitionProxy parent, List<? extends NodeDefinition> list) {
    List<NodeDefinitionProxy> proxies = new ArrayList<NodeDefinitionProxy>();
    if (list != null) {
        for (NodeDefinition n : list) {
            NodeDefinitionProxy p = null;
            CollectSurvey survey = (CollectSurvey) n.getSurvey();
            UIOptions uiOptions = survey.getUIOptions();
            boolean hidden = uiOptions.isHidden(n);
            if (!hidden) {
                if (n instanceof AttributeDefinition) {
                    if (n instanceof BooleanAttributeDefinition) {
                        p = new BooleanAttributeDefinitionProxy(parent, (BooleanAttributeDefinition) n);
                    } else if (n instanceof CodeAttributeDefinition) {
                        p = new CodeAttributeDefinitionProxy(parent, (CodeAttributeDefinition) n);
                    } else if (n instanceof CoordinateAttributeDefinition) {
                        p = new CoordinateAttributeDefinitionProxy(parent, (CoordinateAttributeDefinition) n);
                    } else if (n instanceof DateAttributeDefinition) {
                        p = new DateAttributeDefinitionProxy(parent, (DateAttributeDefinition) n);
                    } else if (n instanceof FileAttributeDefinition) {
                        p = new FileAttributeDefinitionProxy(parent, (FileAttributeDefinition) n);
                    } else if (n instanceof NumberAttributeDefinition) {
                        p = new NumberAttributeDefinitionProxy(parent, (NumberAttributeDefinition) n);
                    } else if (n instanceof RangeAttributeDefinition) {
                        p = new RangeAttributeDefinitionProxy(parent, (RangeAttributeDefinition) n);
                    } else if (n instanceof TaxonAttributeDefinition) {
                        p = new TaxonAttributeDefinitionProxy(parent, (TaxonAttributeDefinition) n);
                    } else if (n instanceof TextAttributeDefinition) {
                        p = new TextAttributeDefinitionProxy(parent, (TextAttributeDefinition) n);
                    } else if (n instanceof TimeAttributeDefinition) {
                        p = new TimeAttributeDefinitionProxy(parent, (TimeAttributeDefinition) n);
                    } else {
                        throw new RuntimeException("AttributeDefinition not supported: " + n.getClass().getSimpleName());
                    }
                } else if (n instanceof EntityDefinition) {
                    p = new EntityDefinitionProxy(parent, (EntityDefinition) n);
                }
                if (p != null) {
                    proxies.add(p);
                }
            }
        }
    }
    return proxies;
}
Also used : TaxonAttributeDefinition(org.openforis.idm.metamodel.TaxonAttributeDefinition) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) FileAttributeDefinition(org.openforis.idm.metamodel.FileAttributeDefinition) CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) NumberAttributeDefinition(org.openforis.idm.metamodel.NumberAttributeDefinition) TimeAttributeDefinition(org.openforis.idm.metamodel.TimeAttributeDefinition) BooleanAttributeDefinition(org.openforis.idm.metamodel.BooleanAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) TextAttributeDefinition(org.openforis.idm.metamodel.TextAttributeDefinition) RangeAttributeDefinition(org.openforis.idm.metamodel.RangeAttributeDefinition) DateAttributeDefinition(org.openforis.idm.metamodel.DateAttributeDefinition) TaxonAttributeDefinition(org.openforis.idm.metamodel.TaxonAttributeDefinition) DateAttributeDefinition(org.openforis.idm.metamodel.DateAttributeDefinition) CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) BooleanAttributeDefinition(org.openforis.idm.metamodel.BooleanAttributeDefinition) FileAttributeDefinition(org.openforis.idm.metamodel.FileAttributeDefinition) TimeAttributeDefinition(org.openforis.idm.metamodel.TimeAttributeDefinition) NumberAttributeDefinition(org.openforis.idm.metamodel.NumberAttributeDefinition) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) TextAttributeDefinition(org.openforis.idm.metamodel.TextAttributeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey) RangeAttributeDefinition(org.openforis.idm.metamodel.RangeAttributeDefinition)

Aggregations

FileAttributeDefinition (org.openforis.idm.metamodel.FileAttributeDefinition)8 File (java.io.File)2 FileAttribute (org.openforis.idm.model.FileAttribute)2 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)1 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)1 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)1 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)1 DateAttributeDefinition (org.openforis.idm.metamodel.DateAttributeDefinition)1 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)1 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)1 NumberAttributeDefinition (org.openforis.idm.metamodel.NumberAttributeDefinition)1 RangeAttributeDefinition (org.openforis.idm.metamodel.RangeAttributeDefinition)1 TaxonAttributeDefinition (org.openforis.idm.metamodel.TaxonAttributeDefinition)1 TextAttributeDefinition (org.openforis.idm.metamodel.TextAttributeDefinition)1 TimeAttributeDefinition (org.openforis.idm.metamodel.TimeAttributeDefinition)1