DSpace dspace = new DSpace();
VisualizationGraphSolrService service = dspace.getServiceManager()
.getServiceByName("visualNetworkSolrService",
VisualizationGraphSolrService.class);
ApplicationService applicationService = dspace.getServiceManager()
.getServiceByName("applicationService",
ApplicationService.class);
CommandLineParser parser = new PosixParser();
Options options = new Options();
options.addOption("h", "help", false, "help");
options.addOption("a", "all_connections", false,
"Work on all connections read from configuration");
options.addOption("s", "single_connection", true,
"Work on single connection");
CommandLine line = parser.parse(options, args);
if (line.hasOption('h'))
{
HelpFormatter myhelp = new HelpFormatter();
myhelp.printHelp("ScriptMetricsNetwork \n", options);
System.out
.println("\n\nUSAGE:\n ScriptMetricsNetwork -a|-s <connection_name>] \n");
System.exit(0);
}
if (line.hasOption('a') && line.hasOption('s'))
{
System.out
.println("\n\nUSAGE:\n ScriptMetricsNetwork -a|-s <connection_name>] \n");
System.out.println("Insert either a or s like parameters");
log.error("Either a or s like parameters");
System.exit(1);
}
List<String> discardedConnection = new LinkedList<String>();
List<String[]> discardedNode = new LinkedList<String[]>();
List<String> connections = new LinkedList<String>();
Integer importedNodes = 0;
Boolean otherError = false;
if (line.hasOption('a'))
{
String connectionsString = ConfigurationManager.getProperty(NetworkPlugin.CFG_MODULE, ConstantNetwork.CONFIG_CONNECTIONS);
if (connectionsString == null || connectionsString.isEmpty())
{
System.out
.println("\n\nUSAGE:\n ScriptMetricsNetwork -a|-s <connection_name>] \n");
System.out
.println("Error to get configuration values, check your dspace.cfg");
log.error("Error to get configuration values, check your dspace.cfg");
System.exit(1);
}
else
{
for (String connection : connectionsString.split(","))
{
connections.add(connection);
}
}
}
else
{
if (line.hasOption('s'))
{
// get researcher by parameter
String connection = line.getOptionValue("s");
if (connection == null || connection.isEmpty())
{
System.out
.println("\n\nUSAGE:\n ScriptMetricsNetwork -a|-s <connection_name>] \n");
System.out
.println("Connection name parameter is needed after option -s");
log.error("Connection name parameter is needed after option -s");
System.exit(1);
}
log.info("Script launched with -s parameter...it will work on connection with name "
+ connection);
connections.add(connection);
}
}
external: for (String connection : connections)
{
boolean exit = false;
// check rp configuration
RPPropertiesDefinition rpPropertiesDefinition = null;
rpPropertiesDefinition = applicationService
.findPropertiesDefinitionByShortName(
RPPropertiesDefinition.class,
ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_1
+ connection);
if (rpPropertiesDefinition == null)
{
System.out
.println("\n\nMETADATA NOT FOUND:\n ScriptMetricsNetwork has relieved that "
+ ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_1
+ connection
+ " missed on configuration, add its on RP properties definition \n");
log.error("METADATA NOT FOUND:\n ScriptMetricsNetwork has relieved that "
+ ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_1
+ connection
+ " missed on configuration, add its on RP properties definition");
exit = true;
}
rpPropertiesDefinition = null;
rpPropertiesDefinition = applicationService
.findPropertiesDefinitionByShortName(
RPPropertiesDefinition.class,
ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_2
+ connection);
if (rpPropertiesDefinition == null)
{
System.out
.println("\n\nMETADATA NOT FOUND:\n ScriptMetricsNetwork has relieved that "
+ ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_2
+ connection
+ " missed on configuration, add its on RP properties definition \n");
log.error("METADATA NOT FOUND:\n ScriptMetricsNetwork has relieved that "
+ ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_2
+ connection
+ " missed on configuration, add its on RP properties definition");
exit = true;
}
rpPropertiesDefinition = null;
rpPropertiesDefinition = applicationService
.findPropertiesDefinitionByShortName(
RPPropertiesDefinition.class,
ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_3
+ connection);
if (rpPropertiesDefinition == null)
{
System.out
.println("\n\nMETADATA NOT FOUND:\n ScriptMetricsNetwork has relieved that "
+ ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_3
+ connection
+ " missed on configuration, add its on RP properties definition \n");
log.error("METADATA NOT FOUND:\n ScriptMetricsNetwork has relieved that "
+ ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_3
+ connection
+ " missed on configuration, add its on RP properties definition");
exit = true;
}
rpPropertiesDefinition = null;
rpPropertiesDefinition = applicationService
.findPropertiesDefinitionByShortName(
RPPropertiesDefinition.class,
ConstantNetwork.PREFIX_METADATA_BIBLIOMETRIC_4
+ connection);
if (rpPropertiesDefinition == null)