Skip to content

Commit

Permalink
Database batch edit (Save mode):
Browse files Browse the repository at this point in the history
- Avoid double indexing of the updated metadata.
- Return the XML document after saving it in the database, applying update-fixed-info process.
  • Loading branch information
josegar74 committed Oct 15, 2024
1 parent eb1a2e9 commit c539dc1
Showing 1 changed file with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2001-2016 Food and Agriculture Organization of the
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
Expand All @@ -26,24 +26,17 @@
import jeeves.server.context.ServiceContext;
import org.apache.commons.lang.StringUtils;
import org.fao.geonet.api.processing.report.MetadataReplacementProcessingReport;
import org.fao.geonet.api.processing.report.XsltMetadataProcessingReport;
import org.fao.geonet.domain.AbstractMetadata;
import org.fao.geonet.domain.ISODate;
import org.fao.geonet.kernel.AccessManager;
import org.fao.geonet.kernel.DataManager;
import org.fao.geonet.kernel.SchemaManager;
import org.fao.geonet.kernel.datamanager.IMetadataManager;
import org.fao.geonet.kernel.datamanager.IMetadataSchemaUtils;
import org.fao.geonet.kernel.datamanager.IMetadataUtils;
import org.fao.geonet.kernel.search.IndexingMode;
import org.fao.geonet.kernel.setting.SettingManager;
import org.fao.geonet.lib.Lib;
import org.fao.geonet.repository.MetadataRepository;
import org.fao.geonet.repository.MetadataValidationRepository;
import org.fao.geonet.utils.Xml;
import org.jdom.Element;

import java.util.Map;

public class DatabaseProcessUtils {
/**
Expand Down Expand Up @@ -72,7 +65,7 @@ public static Element process(ServiceContext context, String id,
return null;
}

int iId = Integer.valueOf(id);
int iId = Integer.parseInt(id);
AbstractMetadata info = metadataUtils.findOne(id);


Expand Down Expand Up @@ -108,16 +101,12 @@ public static Element process(ServiceContext context, String id,
boolean ufo = true;
String language = context.getLanguage();

dataMan.updateMetadata(context, id, wellFormedXml, validate, ufo, language, new ISODate().toString(),
AbstractMetadata metadata = dataMan.updateMetadata(context, id, wellFormedXml, validate, ufo, language, new ISODate().toString(),
updateDateStamp, index ? IndexingMode.full : IndexingMode.none);
if (index) {
dataMan.indexMetadata(id, true);
}
wellFormedXml = Xml.loadString(metadata.getData(), false);
}
}



report.addMetadataId(iId);
// TODO : it could be relevant to list at least
// if there was any change in the record or not.
Expand Down

0 comments on commit c539dc1

Please sign in to comment.