Code redesign
Refs #11756: Refactor DataHArvesterPlugin to support scheduled execution from smart-executor Task-Url: https://support.d4science.org/issues/11756 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-dashboard-harvester-se-plugin@167646 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
559251fe2f
commit
72f29300c9
|
@ -61,7 +61,7 @@ public abstract class SoBigDataHarvester extends BasicHarvester {
|
||||||
return res.get(0);
|
return res.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SortedSet<String> getExcludedContexts() {
|
public SortedSet<String> getExcludedContexts() {
|
||||||
SortedSet<String> excludedContexts = new TreeSet<>();
|
SortedSet<String> excludedContexts = new TreeSet<>();
|
||||||
|
|
||||||
GenericResource genericResource = getGenericResource();
|
GenericResource genericResource = getGenericResource();
|
||||||
|
@ -89,15 +89,36 @@ public abstract class SoBigDataHarvester extends BasicHarvester {
|
||||||
logger.info("The body of the {} does not contains any information to filter contexts.", GenericResource.class.getSimpleName());
|
logger.info("The body of the {} does not contains any information to filter contexts.", GenericResource.class.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
Node node = nodeList.item(0).getChildNodes().item(1);
|
Element classNameElement = null;
|
||||||
NodeList contexts = node.getChildNodes();
|
for(int c=0; c<nodeList.getLength(); c++) {
|
||||||
|
Node node = nodeList.item(c);
|
||||||
|
if(node.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
|
classNameElement = (Element) node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Element vresElement = null;
|
||||||
|
NodeList vresNodeList = classNameElement.getElementsByTagName("vres");
|
||||||
|
for(int c=0; c<vresNodeList.getLength(); c++) {
|
||||||
|
Node node = vresNodeList.item(c);
|
||||||
|
if(node.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
|
vresElement = (Element) node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeList vreNodeList = vresElement.getElementsByTagName("vre");
|
||||||
|
for(int c=0; c<vreNodeList.getLength(); c++) {
|
||||||
|
Node node = vreNodeList.item(c);
|
||||||
|
if(node.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
|
Element vreElement = (Element) node;
|
||||||
|
NodeList nl = vreElement.getChildNodes();
|
||||||
|
for(int i=0; i<nl.getLength(); i++) {
|
||||||
|
Node n = nl.item(i);
|
||||||
|
if(n.getNodeType() == Node.TEXT_NODE) {
|
||||||
|
excludedContexts.add(n.getNodeValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(int i=1; i<contexts.getLength()-1; i++){
|
|
||||||
Node context = contexts.item(i);
|
|
||||||
NodeList nList = context.getChildNodes();
|
|
||||||
if(nList.item(0)!=null) {
|
|
||||||
String contextToExclude = nList.item(0).getNodeValue();
|
|
||||||
excludedContexts.add(contextToExclude);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,9 +137,11 @@ public class AccountingDataHarvesterPluginTest extends ContextTest {
|
||||||
SortedSet<String> contexts = contextAuthorization.getContexts();
|
SortedSet<String> contexts = contextAuthorization.getContexts();
|
||||||
|
|
||||||
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end, contexts);
|
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end, contexts);
|
||||||
|
SortedSet<String> excludedContexts = resourceCatalogueHarvester.getExcludedContexts();
|
||||||
|
logger.info("Excluded contexts {}", excludedContexts);
|
||||||
SortedSet<String> validContexts = resourceCatalogueHarvester.getFilteredContexts();
|
SortedSet<String> validContexts = resourceCatalogueHarvester.getFilteredContexts();
|
||||||
|
|
||||||
logger.info("{}", validContexts);
|
logger.info("Valid Contexts {}", validContexts);
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
logger.error("", e);
|
logger.error("", e);
|
||||||
|
|
Loading…
Reference in New Issue