Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* $Id:
*
* $Log:
*/
package decodes.tsdb;
import java.util.ArrayList;
import opendcs.dai.SiteDAI;
import opendcs.dai.TimeSeriesDAI;
import opendcs.dai.TsGroupDAI;
import decodes.db.Constants;
import decodes.sql.DbKey;
import decodes.tsdb.xml.CompXio;
import decodes.tsdb.xml.DbXmlException;
import decodes.util.AppMessages;
import decodes.util.CmdLineArgs;
import ilex.cmdline.BooleanToken;
import ilex.cmdline.StringToken;
import ilex.cmdline.TokenOptions;
import ilex.util.Logger;
/**
* Create on Dec 22, 2010
*
* @author gchen
*
*
*/
public class ImportGroup extends TsdbAppTemplate
{
private StringToken xmlFileArgs;
private BooleanToken createTimeSeries;
private String appModule = "ImpTSGrp";
private SiteDAI siteDAO = null;
private enum LookupObjectType {TsUniqStr, SiteId, InclSubgrp, ExclSubgrp};
/**
* @param logname
*/
public ImportGroup()
{
super("util.log");
setSilent(true);
}
public void addCustomArgs(CmdLineArgs cmdLineArgs)
{
createTimeSeries = new BooleanToken("C", "create parms as needed",
"", TokenOptions.optSwitch, false);
cmdLineArgs.addToken(createTimeSeries);
xmlFileArgs = new StringToken("", "xml-file",
"", TokenOptions.optArgument | TokenOptions.optMultiple|
TokenOptions.optRequired, "");
cmdLineArgs.addToken(xmlFileArgs);
}
/**
* Sort the TS Group List with searching subgroups for each TS group and
* putting them in the front of each referring TS group.
*
* @param tsGrpsList: a TsGroup array list for sorting
* @return ArrayList: sorted TsGroup array list
*/
protected ArrayList sortTsGroupList(ArrayList tsGrpsList)
{
if ((tsGrpsList == null) || (tsGrpsList.size() == 0))
return null;
ArrayList retTsGrpsList = new ArrayList();
for(TsGroup tsGrp: tsGrpsList) {
for(TsGroup tsSubGrp: tsGrp.getIncludedSubGroups())
addTheTSGroup(tsSubGrp, tsGrpsList, retTsGrpsList);
for(TsGroup tsSubGrp: tsGrp.getExcludedSubGroups())
addTheTSGroup(tsSubGrp, tsGrpsList, retTsGrpsList);
addTheTSGroup(tsGrp, tsGrpsList, retTsGrpsList);
}
tsGrpsList.clear();
return retTsGrpsList;
}
/**
* Add a TS group object found from the fromTsGroupList into
* the toTsGroupList which does not contain the TS group object.
*
* @param tsGrp
* @param fromTSGrpList
* @param toTSGrpList
*/
private void addTheTSGroup(TsGroup tsGrp,
ArrayList fromTsGrpList, ArrayList toTsGrpList)
{
if (toTsGrpList == null)
return;
if (toTsGrpList.size() == 0) {
//Add the tsGrp object found from the fromTsGrpList into the toTsGrpList
if (fromTsGrpList != null)
for(TsGroup g: fromTsGrpList)
if (g.getGroupName().equals(tsGrp.getGroupName())) {
toTsGrpList.add(g);
break;
}
return;
}
//Search if the tsGrp already exists in the toTsGrpList
boolean hasTheTsGrp = false;
for(TsGroup g: toTsGrpList) {
if (g.getGroupName().equals(tsGrp.getGroupName())) {
hasTheTsGrp = true;
break;
}
}
//Add the tsGrp object found from the fromTsGrpList into the toTsGrpList
if (!hasTheTsGrp && (fromTsGrpList != null))
for(TsGroup g: fromTsGrpList)
if (g.getGroupName().equals(tsGrp.getGroupName())) {
toTsGrpList.add(g);
break;
}
}
/**
* Lookup if a certain object exists in the DB. If not, ignore it within the imported TS group
*
* @param tsGrp: TS group needs to be expanded for certain object
* @param lookupObjType: a certain object type, TsUniqStr - time series unique string;
* SiteId - site ID;
* InclSubgrp - included subgroup
* ExclSubgrp - excluded subgroup
*/
protected void lookupObject(TsGroup tsGrp, LookupObjectType lookupObjType, TsGroupDAI groupDAO)
{
ArrayList