As the title says, I’m attempting to copy the tags from the default tag provider into an empty database. However, I’m not sure if what I have (shown below) is actually reading the tags. The project builds, but I don’t see any change to my database (which seems to have a valid connection according to the gateway webpage.
public class TagListener implements TagChangeListener {
TagPath path;
SRConnection dbconnection;
GatewayContext context;
public TagListener(TagPath path) {
this.path= path;
// TODO Auto-generated constructor stub
}
private final Logger log = Logger.getLogger(getClass());
@Override
public TagProp getTagProperty() {
// TODO Auto-generated method stub
return null;
}
@Override
public void tagChanged(TagChangeEvent arg0) {
List <TagPath> list= new ArrayList<TagPath>();//creates list with type TagPath
list.add(path);//adds path to list
List<QualifiedValue> tags= context.getTagManager().read(list);//reads list to access tags
log.error("Value : "+ tags.get(0).getValue());
datacopy(tags);//
}
public void readingTest() throws IOException{
TagPath myPath= TagPathParser.parse("[default]");
TagListener listener=new TagListener(myPath) {
};
List <TagPath> list2= new ArrayList<TagPath>();
lista.add(myPath);
context.getTagManager().subscribe(myPath, listener);
System.out.println(list2);
}
public void datacopy(List ltags) {
try {
dbconnection=context.getDatasourceManager().getConnection("ModTest");//connect to db
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String query = String.format("INSERT INTO [ModTAGS].[dbo].[ModuleTags] VALUES ('%s')",ltags);//insert tag list
try {
dbconnection.runPrepQuery(query);//insert tag list
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Any help is appreciated.