4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
SugPersonAttribute.java
Go to the documentation of this file.
1 /*
2  * Project: Server for annotations sharing
3  * Author: Ing. Jaroslav Dytrych idytrych@fit.vutbr.cz
4  * File: SugPersonAttribute.java
5  * Description: Class representing attribute of type Person for peupose of suggestion
6  */
7 
8 package cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes;
9 
13 import javax.persistence.DiscriminatorValue;
14 import javax.persistence.Entity;
15 import javax.persistence.NamedQueries;
16 import javax.persistence.NamedQuery;
17 
18 /**
19  * @file SugPersonAttribute.java
20  *
21  * @brief Class representing attribute of type Person for peupose of suggestion
22  */
23 
24 /**
25  * Class representing attribute of type Person for peupose of suggestion
26  *
27  * @brief Class representing attribute of type Person for peupose of suggestion
28  */
29 @Entity
30 @DiscriminatorValue("person")
31 @NamedQueries({
32  @NamedQuery(name = "SuggestionAttribute.findByUserValue", query = "SELECT a FROM SuggestionAttribute a WHERE a.userValue = :userValue"),
33 })
35  /**
36  * Constructor
37  */
38  public SugPersonAttribute() {
39  }
40 
41  /**
42  * Constructor of attribute of type Person
43  *
44  * @param name Name of attribute
45  * @param person Value of attribute person (user)
46  * @param refSuggestion Suggestion to which this attribute belongs
47  */
48  public SugPersonAttribute(String name, User person, Suggestion refSuggestion) {
49  this.name = name;
50  this.simpleType = "person";
51  this.refSuggestion = refSuggestion;
52  this.user = person;
53  }
54 
55  /**
56  * Gets value of the attribute
57  *
58  * @return value of the attribute
59  */
60  @Override
61  public Object getValue() {
62  return this.user;
63  }
64 
65  /**
66  * Sets value of the attribute. Value should already be a native java value.
67  *
68  * @param person New value of the attribute
69  */
70  @Override
71  public void setValue(Object person) {
72  this.user = (User) person;
73  }
74 
75  /**
76  * XML of the structured attribute looks like this:
77  * @verbatim
78  * <a:attribute ...... >
79  * <nested>
80  * <value1>...</value1>
81  * <value2>...</value2>
82  * </nested>
83  * </a:attribute>
84  * @endverbatim
85  *
86  * This method returns the content of the a:attribute element with all nested
87  * elements.
88  *
89  * @return Returns the content of the a:attribute element with all nested elements.
90  */
91  @Override
92  protected String getXmlBody() {
93  return "<a:person id=\"" + user.getEmail() + "\"/>";
94  }
95 
96  /**
97  * Parses provided value and sets that value as a value of attribute
98  *
99  * This method should not be used, because this type of attribute is processed
100  * in MessageProcessor.
101  *
102  * @param values new value of the attribute in raw form from XML
103  */
104  @Override
105  public void setRawValues(Object values) throws IllegalArgumentException {
106  throw new UnsupportedOperationException("Server internal error.");
107  }
108 
109  /**
110  * XML of the structured attribute looks like this:
111  * @verbatim
112  * <a:attribute ...... >
113  * <nested>
114  * <value1>...</value1>
115  * <value2>...</value2>
116  * </nested>
117  * </a:attribute>
118  * @endverbatim
119  *
120  * @return the name of the "nested" attribute , which is "Person" for this type
121  */
122  @Override
123  public String getXmlAttributeName() {
124  return "Person";
125  }
126 
127  /**
128  * Gets URI addres in ontology for this type of attribute
129  *
130  * @return Return URI addres in ontology for this type of attribute.
131  */
132  @Override
133  public String getTypeOntologyUri(){
134  return Constants.PERSON_URI;
135  }
136 }
Class representing user.
Definition: User.java:51
Class representing suggestion of annotation.
Definition: Suggestion.java:87
Class representing attribute of type Person for peupose of suggestion.