Mercurial > hg > LGServices
diff src/main/java/de/mpiwg/gazetteer/utils/DataProvider.java @ 55:95bf4ac726e6
Topic synchronization with extraction-interface. new tables in LGService database
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 16 Feb 2016 15:09:40 +0100 |
parents | a00efd5d9e77 |
children | 7e161f2e6660 |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/gazetteer/utils/DataProvider.java Thu Feb 04 11:30:46 2016 +0100 +++ b/src/main/java/de/mpiwg/gazetteer/utils/DataProvider.java Tue Feb 16 15:09:40 2016 +0100 @@ -14,8 +14,10 @@ import de.mpiwg.gazetteer.bo.LGBranch; import de.mpiwg.gazetteer.bo.LGFile; import de.mpiwg.gazetteer.bo.LGFullTextSearchFile; +import de.mpiwg.gazetteer.bo.LGTaglist; import de.mpiwg.gazetteer.bo.LGTopic; import de.mpiwg.gazetteer.bo.LGTopicSectionRelation; +import de.mpiwg.gazetteer.bo.LGTopicTagRelation; import de.mpiwg.gazetteer.db.DBContents; import de.mpiwg.gazetteer.db.DBSection; import de.mpiwg.gazetteer.utils.exceptions.NoAuthorizedException; @@ -372,11 +374,10 @@ int modifiedRelation = DBService.deleteTopicFromDB(topic.getId()); getTopicMap().remove(topic.getKey()); - logger.info("removing " + modifiedRelation + " records in topicSectionRelation of topic " + topic.toString()); + logger.info("removing " + modifiedRelation + " records in TopicSectionRelation and TopicTagRelation table for the topic " + topic.toString()); this.setTopicSectionRelationMap(null); // clear topicSectionRelationMap cache - } public void createTopic(String nameEn, String nameCh,String namePinyin, String description, Long userId) { @@ -390,6 +391,11 @@ topic.setUserId(userId); topic.setContributors("[" + userId.toString() + "]"); + // auto-generating a tag for the topic: could be from nameEn replace space with '_' + String tag = new String(); + tag = nameEn.replace(' ', '_'); + topic.setTag(tag); + //Saving into DB //################################## // For Topic table @@ -398,6 +404,30 @@ DBService.saveDBEntry0(session, topic, date); + // For Taglist table + // create record, which is the topic tag, in taglist table, + // with the taglis.name=nameCh, the taglist.tag=tag, the taglist.color=the defualt topic tag color, which is rgb(255,0,174) + + LGTaglist taglist = new LGTaglist(); + taglist.setName(nameCh); + taglist.setTag(tag); + taglist.setColor("rgb(255, 0, 174)"); + + DBService.saveDBEntry0(session, taglist, date); + + + logger.debug("new topic tag id=" + taglist.getId()); + + + // For TopicTagRelation table + // link the relation between the new topic and its corresponding tag + LGTopicTagRelation relation = new LGTopicTagRelation(); + relation.setTagId(taglist.getId()); + relation.setTopicId(topic.getId()); + + DBService.saveDBEntry0(session, relation, date); + + session.getTransaction().commit(); //##################################