use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class SpeciesService method deleteTaxonomy.
@Secured("ROLE_ADMIN")
public void deleteTaxonomy(TaxonomyProxy proxy) {
CollectSurvey survey = sessionManager.getActiveDesignerSurvey();
Integer taxonomyId = proxy.getId();
CollectTaxonomy taxonomy = speciesManager.loadTaxonomyById(survey, taxonomyId);
speciesManager.delete(taxonomy);
deleteReferencingAttributes(taxonomy);
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class DataRestoreServiceImpl method checkValidSurvey.
private void checkValidSurvey(String surveyName, String surveyUri) {
CollectSurvey expectedSurvey = surveyManager.get(surveyName);
String expectedSurveyUri = expectedSurvey.getUri();
if (!surveyUri.equals(expectedSurveyUri)) {
throw new IllegalArgumentException("The backup file is not related to the specified survey");
}
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class DataCSVReader method calculateIgnoredColumns.
private List<String> calculateIgnoredColumns() {
final CSVDataExportParameters csvExportConfig = new CSVDataExportParameters();
csvExportConfig.setIncludeCodeItemLabelColumn(true);
csvExportConfig.setIncludeEnumeratedEntities(false);
CollectSurvey survey = (CollectSurvey) parentEntityDefinition.getSurvey();
ColumnProviderChain columnProvider = new CSVDataExportColumnProviderGenerator(survey, csvExportConfig).generateColumnProviderChain(parentEntityDefinition);
List<String> result = new ArrayList<String>();
List<String> colNames = getColumnNames();
for (final String colName : colNames) {
final MutableBoolean ignored = new MutableBoolean(false);
columnProvider.traverseProviders(new Visitor<ColumnProvider>() {
public void visit(ColumnProvider p) {
if (!(p instanceof ColumnProviderChain) && p instanceof BasicColumnProvider) {
List<String> finalColumnHeadings = ((BasicColumnProvider) p).generateFinalColumnHeadings();
if (finalColumnHeadings.contains(colName)) {
if (p instanceof CodeColumnProvider && colName.endsWith(csvExportConfig.getFieldHeadingSeparator() + CodeColumnProvider.ITEM_LABEL_SUFFIX)) {
ignored.setTrue();
}
}
}
}
});
if (ignored.booleanValue()) {
result.add(colName);
}
}
return result;
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class XMLDataImportProcess method loadExistingSurvey.
protected CollectSurvey loadExistingSurvey() {
String uri;
if (surveyUri == null) {
if (packagedSurvey == null) {
throw new IllegalStateException("Survey uri not specified and packaged survey not found");
} else {
uri = packagedSurvey.getUri();
}
} else {
uri = surveyUri;
}
CollectSurvey survey = surveyManager.getByUri(uri);
if (survey == null && surveyUri != null) {
throw new IllegalArgumentException("Published survey not found. URI: " + surveyUri);
} else {
return survey;
}
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class DataRestoreBaseJob method validateInput.
@Override
protected void validateInput() throws Throwable {
super.validateInput();
BackupFileExtractor backupFileExtractor = null;
try {
backupFileExtractor = new BackupFileExtractor(file);
if (backupFileExtractor.isOldFormat()) {
if (publishedSurvey == null) {
throw new IllegalArgumentException("Please specify a published survey to witch restore data into");
}
} else {
SurveyBackupInfo backupInfo = backupFileExtractor.extractInfo();
CollectSurvey existingPublishedSurvey = findExistingPublishedSurvey(backupInfo);
boolean newSurvey = publishedSurvey == null;
if (newSurvey) {
if (existingPublishedSurvey != null) {
throw new IllegalArgumentException(String.format("The backup file is associated to an already published survey: %s", existingPublishedSurvey.getName()));
}
} else {
String publishedSurveyUri = publishedSurvey.getUri();
String packagedSurveyUri = backupInfo.getSurveyUri();
if (!publishedSurveyUri.equals(packagedSurveyUri)) {
throw new RuntimeException(String.format("Packaged survey uri (%s) is different from the expected one (%s)", packagedSurveyUri, publishedSurveyUri));
}
}
}
} finally {
IOUtils.closeQuietly(backupFileExtractor);
}
}
Aggregations