14 package cz.vutbr.fit.knot.annotations.modules.StoryscopeInterface;
19 import java.io.Serializable;
20 import java.util.ArrayList;
21 import java.util.Iterator;
22 import java.util.List;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25 import javax.persistence.Basic;
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.GeneratedValue;
29 import javax.persistence.GenerationType;
30 import javax.persistence.Id;
31 import javax.persistence.NamedQueries;
32 import javax.persistence.NamedQuery;
33 import javax.persistence.Table;
34 import javax.persistence.Transient;
44 @Table(name =
"storyScopes")
46 @NamedQuery(name =
"StoryScope.findAll", query =
"SELECT s FROM StoryScope s"),
47 @NamedQuery(name =
"StoryScope.findById", query =
"SELECT s FROM StoryScope s WHERE s.id = :id")})
51 @GeneratedValue(strategy = GenerationType.IDENTITY)
52 @Basic(optional =
false)
57 @Basic(optional = false)
58 @Column(name = "name")
62 @Basic(optional = false)
63 @Column(name = "clientUrl")
64 private String clientURL;
67 private ArrayList<String> addMessages = null;
70 private ArrayList<String> changeMessages = null;
73 private ArrayList<String> deleteMessages = null;
88 public StoryScope(Integer
id, String name, String clientURL){
91 this.clientURL = clientURL;
145 this.clientURL = clientURL;
154 Object[] params = {
"storyScope",
id};
155 @SuppressWarnings(
"unchecked")
156 List<Object> retList = AppBean.getPersistenceManager().queryDB(
"SubscribedItem.findSubscribed", params);
169 Object[] params = {
"storyScope",
id};
171 @SuppressWarnings(
"unchecked")
172 ArrayList<SubscribedSource> retList = this.makeArrayList(AppBean.getPersistenceManager().queryDB(
"SubscribedItem.findSubscribed",params));
184 Object[] params = {
"storyScope",
id};
186 @SuppressWarnings(
"unchecked")
187 ArrayList<SubscribedSource> retList = this.makeArrayList(AppBean.getPersistenceManager().queryDB(
"SubscribedItem.findUnsubscribed",params));
226 Object[] params = {
"storyScopeId",
id};
228 @SuppressWarnings(
"unchecked")
229 List<SavedMessage> messages = AppBean.getPersistenceManager().queryDB(
"SavedMessage.findByStoryScopeId",params);
232 if(messages != null){
233 Iterator <SavedMessage> messagesIt = messages.iterator();
234 while(messagesIt.hasNext()){
238 String msg =
"DB failure during deleting saved message form StoryScope account.";
239 Logger.getLogger(StoryScope.class.getName()).log(Level.SEVERE, msg);
254 Iterator<String> messagesIt = messages.iterator();
255 while(messagesIt.hasNext()){
261 String msg =
"DB failure during saving message for StoryScope account.";
262 Logger.getLogger(StoryScope.class.getName()).log(Level.SEVERE, msg);
271 hash += (
id != null ? id.hashCode() : 0);
288 if ((this.
id == null && tested.
id != null) || (this.id != null && !this.id.equals(tested.id))) {
296 return "cz.vutbr.fit.knot.annotations.modules.StoryscopeInterface.StoryScope[id=" +
id +
", name=" + name +
", client URL=" + clientURL +
"]";
306 private ArrayList<SubscribedSource>
makeArrayList(List<SubscribedItem> objList){
307 if(objList == null || objList.isEmpty())
return null;
308 ArrayList <SubscribedSource> arrList =
new ArrayList <SubscribedSource>();
309 Iterator objListIterator = objList.iterator();
311 while(objListIterator.hasNext()){
316 String source = null;
319 type = listElement.getAnnotationType().getUri();
322 if(listElement.
getUser() != null){
323 user = listElement.getUser().getURI();
326 source = listElement.getSource();
330 arrList.add(newSource);
344 ArrayList<String> result =
new ArrayList<String>();
345 if(savedMessages != null)
347 Iterator<SavedMessage> messagesIt = savedMessages.iterator();
348 while(messagesIt.hasNext()){
349 result.add(messagesIt.next().getMessage());
363 Iterator<String> messagesIt = messages.iterator();
365 while(messagesIt.hasNext()){
366 result += messagesIt.next();
379 Object[] params = {
"storyScopeId",id,
380 "messageType",typeOfMessages};
381 @SuppressWarnings(
"unchecked")
382 List<SavedMessage> retList = AppBean.getPersistenceManager().queryDB(
"SavedMessage.findByStoryScopeAndType",params);
void setClientURL(String clientURL)
static final int MESSAGE_CHANGE
void setName(String name)
Class representing StoryScope for needs of SEC Interface.
String getMessagesChange()
Singleton for storing global variables.
void addSavedMessages(ArrayList< String > messages, int type)
ArrayList< SubscribedSource > getSubscribedList()
List< Object > getSubscriptions()
static String messagesToString(ArrayList< String > messages)
ArrayList< String > savedMessagesToAL(List< SavedMessage > savedMessages)
static final int LOG_LEVEL
Class representing item of subscripted or unsubscripted sources list.
StoryScope(Integer id, String name, String clientURL)
String getMessagesDelete()
static PersistM getPersistenceManager()
List< SavedMessage > getSavedMessagesFromDB(int typeOfMessages)
static final int LOG_LEVEL_SERVER_ERRORS
static final int MESSAGE_DELETE
ArrayList< SubscribedSource > makeArrayList(List< SubscribedItem > objList)
Subscribed source of annotations.
AnnotType getAnnotationType()
static final int MESSAGE_ADD
boolean equals(Object object)
ArrayList< SubscribedSource > getUnsubscribedList()
This class represent saved message that belongs unavailable StoryScope.