Skip to content

Commit e06ea97

Browse files
committed
JPA annotations
1 parent ced94f2 commit e06ea97

File tree

104 files changed

+2442
-2594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+2442
-2594
lines changed

logicaldoc-cmis/src/main/java/com/logicaldoc/cmis/LDRepository.java

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,12 @@ public void appendContent(CallContext context, String documentId, ContentStream
545545
log.debug("appendContent {}", documentId);
546546
AbstractDocument doc = getDocument(documentId);
547547

548-
validatePermission(ID_PREFIX_FLD + doc.getFolder().getId(), context, Permission.WRITE);
548+
long folderId = 0L;
549+
if (doc instanceof Document document)
550+
folderId = document.getFolder().getId();
551+
else if (doc instanceof Version version)
552+
folderId = version.getFolderId();
553+
validatePermission(ID_PREFIX_FLD + folderId, context, Permission.WRITE);
549554

550555
NumberFormat nd = new DecimalFormat("0000000000");
551556

@@ -1213,9 +1218,9 @@ public ContentStream getContentStream(CallContext context, String objectId, BigI
12131218
if (doc instanceof Document document)
12141219
transaction.setDocument(document);
12151220

1216-
if (doc instanceof Document) {
1217-
transaction.setFolderId(doc.getFolder().getId());
1218-
transaction.setPath(folderDao.computePathExtended(doc.getFolder().getId()));
1221+
if (doc instanceof Document document) {
1222+
transaction.setFolderId(document.getFolder().getId());
1223+
transaction.setPath(folderDao.computePathExtended(document.getFolder().getId()));
12191224
} else {
12201225
transaction.setFolderId(((Version) doc).getFolderId());
12211226
transaction.setPath(folderDao.computePathExtended(((Version) doc).getFolderId()));
@@ -1431,7 +1436,7 @@ public List<ObjectParentData> getObjectParents(CallContext context, String objec
14311436
compileObjectType(context, object, null, false, false, objectInfos);
14321437

14331438
Folder parent;
1434-
if (object instanceof AbstractDocument document)
1439+
if (object instanceof Document document)
14351440
parent = document.getFolder();
14361441
else
14371442
parent = folderDao.findFolder(((Folder) object).getParentId());
@@ -1916,8 +1921,14 @@ private void compileDocumentOrVersionProperties(AbstractDocument doc, ObjectInfo
19161921
addPropertyBoolean(result, typeId, filter, PropertyIds.IS_IMMUTABLE, doc.getImmutable() != 0);
19171922

19181923
addPropertyString(result, typeId, filter, TypeManager.PROP_LANGUAGE, doc.getLanguage());
1919-
addPropertyInteger(result, typeId, filter, TypeManager.PROP_RATING,
1920-
doc.getRating() != null ? doc.getRating() : 0);
1924+
1925+
if (doc instanceof Document document) {
1926+
addPropertyInteger(result, typeId, filter, TypeManager.PROP_RATING,
1927+
document.getRating() != null ? document.getRating() : 0);
1928+
} else {
1929+
addPropertyInteger(result, typeId, filter, TypeManager.PROP_RATING, 0);
1930+
}
1931+
19211932
addPropertyString(result, typeId, filter, TypeManager.PROP_FILEVERSION, doc.getFileVersion());
19221933
addPropertyString(result, typeId, filter, TypeManager.PROP_VERSION, doc.getVersion());
19231934
addPropertyString(result, typeId, filter, TypeManager.PROP_CUSTOMID, doc.getCustomId());
@@ -2126,14 +2137,16 @@ private void updateDocumentLocale(AbstractDocument doc, PropertyData<?> p) {
21262137
}
21272138

21282139
private void updateDocumentTags(AbstractDocument doc, PropertyData<?> p) {
2129-
doc.getTags().clear();
2130-
doc.setTgs((String) p.getFirstValue());
2131-
if (doc.getTgs() != null) {
2132-
StringTokenizer st = new StringTokenizer(doc.getTgs(), ",", false);
2133-
while (st.hasMoreTokens()) {
2134-
String tg = st.nextToken();
2135-
if (StringUtils.isNotEmpty(tg))
2136-
doc.addTag(tg);
2140+
if (doc instanceof Document document) {
2141+
document.getTags().clear();
2142+
document.setTgs((String) p.getFirstValue());
2143+
if (document.getTgs() != null) {
2144+
StringTokenizer st = new StringTokenizer(document.getTgs(), ",", false);
2145+
while (st.hasMoreTokens()) {
2146+
String tg = st.nextToken();
2147+
if (StringUtils.isNotEmpty(tg))
2148+
document.addTag(tg);
2149+
}
21372150
}
21382151
}
21392152
}

logicaldoc-core/src/main/java/com/logicaldoc/core/communication/EventCollector.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.logicaldoc.core.RunLevel;
1616
import com.logicaldoc.core.document.Document;
1717
import com.logicaldoc.core.document.DocumentDAO;
18+
import com.logicaldoc.core.history.AbstractDocumentHistory;
1819
import com.logicaldoc.core.history.History;
1920
import com.logicaldoc.core.threading.ThreadPools;
2021
import com.logicaldoc.util.Context;

logicaldoc-core/src/main/java/com/logicaldoc/core/communication/Message.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
import java.util.Locale;
66
import java.util.Set;
77

8+
import javax.persistence.CollectionTable;
9+
import javax.persistence.Column;
10+
import javax.persistence.ElementCollection;
11+
import javax.persistence.JoinColumn;
12+
import javax.persistence.MappedSuperclass;
13+
import javax.persistence.Transient;
14+
815
import com.logicaldoc.core.PersistentObject;
916

1017
/**
@@ -14,6 +21,7 @@
1421
* @author Marco Meschieri
1522
* @version 1.0
1623
*/
24+
@MappedSuperclass
1725
public abstract class Message extends PersistentObject {
1826

1927
private static final long serialVersionUID = 1L;
@@ -22,36 +30,47 @@ public abstract class Message extends PersistentObject {
2230

2331
public static final int TYPE_NOTIFICATION = 1;
2432

25-
private String messageText = "";
26-
33+
@Column(name = "ld_author", length = 255)
2734
private String author = "";
35+
36+
@Column(name = "ld_messagetext")
37+
private String messageText = "";
2838

39+
@Column(name = "ld_subject", length = 255)
2940
private String subject = "";
3041

3142
/**
3243
* When the message was sent
3344
*/
45+
@Column(name = "ld_sentdate", nullable = false)
3446
private Date sentDate = new Date();
3547

3648
/**
3749
* When the message was received
3850
*/
51+
@Transient
3952
private Date receivedDate = new Date();
4053

54+
@Column(name = "ld_type", nullable = false)
4155
private int type = Message.TYPE_SYSTEM;
4256

57+
@ElementCollection
58+
@CollectionTable(name = "ld_recipient", joinColumns = @JoinColumn(name = "ld_messageid"))
4359
private Set<Recipient> recipients = new HashSet<>();
4460

4561
/**
4662
* The locale in which the message is written
4763
*/
64+
@Transient
4865
protected Locale locale;
4966

67+
@Column(name = "ld_html", nullable = false)
5068
protected int html = 0;
5169

5270
/**
5371
* A flag that can be used to specify if the message has to be notified
5472
*/
73+
@Transient
5574
protected boolean notify = true;
5675

5776
public boolean isNotify() {

logicaldoc-core/src/main/java/com/logicaldoc/core/communication/MessageTemplate.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
import java.util.Map;
44

5+
import javax.persistence.Cacheable;
6+
import javax.persistence.Column;
7+
import javax.persistence.Entity;
8+
import javax.persistence.Table;
9+
10+
import org.hibernate.annotations.Cache;
11+
import org.hibernate.annotations.CacheConcurrencyStrategy;
12+
513
import com.logicaldoc.core.PersistentObject;
614
import com.logicaldoc.core.automation.Automation;
715
import com.logicaldoc.core.automation.AutomationException;
@@ -13,6 +21,10 @@
1321
* @author Marco Meschieri - LogicalDOC
1422
* @since 6.5
1523
*/
24+
@Entity
25+
@Table(name = "ld_messagetemplate")
26+
@Cacheable
27+
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
1628
public class MessageTemplate extends PersistentObject {
1729

1830
private static final long serialVersionUID = 1L;
@@ -21,16 +33,22 @@ public class MessageTemplate extends PersistentObject {
2133

2234
public static final String TYPE_USER = "user";
2335

36+
@Column(name = "ld_name", length = 255, nullable = false)
2437
private String name = "";
2538

26-
private String description = "";
27-
39+
@Column(name = "ld_language", length = 10, nullable = false)
2840
private String language = "en";
41+
42+
@Column(name = "ld_description", length = 1000)
43+
private String description = "";
2944

45+
@Column(name = "ld_body", length = 4000)
3046
private String body;
3147

48+
@Column(name = "ld_subject", length = 1000)
3249
private String subject;
3350

51+
@Column(name = "ld_type", length = 255)
3452
private String type = TYPE_SYSTEM;
3553

3654
public MessageTemplate() {

logicaldoc-core/src/main/java/com/logicaldoc/core/communication/Recipient.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
import java.io.Serializable;
44

5+
import javax.persistence.Column;
6+
import javax.persistence.Embeddable;
7+
58
import org.apache.commons.lang3.StringUtils;
69

710
/**
811
* A generic recipient of a message or email
912
*
1013
* @author Michael Scholz
1114
*/
15+
@Embeddable
1216
public class Recipient implements Serializable {
1317

1418
private static final long serialVersionUID = 1L;
@@ -26,18 +30,23 @@ public class Recipient implements Serializable {
2630
public static final String MODE_EMAIL_REPLYTO = "REPLYTO";
2731

2832
// The login
33+
@Column(name = "ld_name", nullable = false)
2934
private String name = "";
3035

3136
// The system login or the email address
37+
@Column(name = "ld_address", nullable = false)
3238
private String address = "";
3339

3440
// The recipient mode (for the system message is not useful, for the email
3541
// can be To, CC, CCN, ecc.)
42+
@Column(name = "ld_mode", nullable = false)
3643
private String mode = MODE_EMAIL_TO;
3744

3845
// The recipient type (i.e. system, user, group, email)
46+
@Column(name = "ld_type", nullable = false)
3947
private int type = TYPE_SYSTEM;
4048

49+
@Column(name = "ld_read", nullable = false)
4150
private int read = 0;
4251

4352
public Recipient(String name, String address) {
@@ -84,7 +93,7 @@ public boolean equals(Object arg0) {
8493

8594
@Override
8695
public int hashCode() {
87-
return address.hashCode();
96+
return address.hashCode();
8897
}
8998

9099
public String getMode() {

logicaldoc-core/src/main/java/com/logicaldoc/core/communication/SystemMessage.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
import java.util.HashSet;
55
import java.util.Set;
66

7+
import javax.persistence.Cacheable;
8+
import javax.persistence.Column;
9+
import javax.persistence.Entity;
10+
import javax.persistence.Table;
11+
12+
import org.hibernate.annotations.Cache;
13+
import org.hibernate.annotations.CacheConcurrencyStrategy;
14+
715
/**
816
* SystemMessages are messages which an user only can send to other system
917
* users.
@@ -12,6 +20,10 @@
1220
* @author Marco Meschieri - LogicalDOC
1321
* @since 1.0
1422
*/
23+
@Entity
24+
@Table(name = "ld_systemmessage")
25+
@Cacheable
26+
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
1527
public class SystemMessage extends Message {
1628

1729
private static final long serialVersionUID = 1L;
@@ -22,25 +34,31 @@ public class SystemMessage extends Message {
2234

2335
public static final int STATUS_ERROR = 2;
2436

37+
@Column(name = "ld_datescope")
2538
private int dateScope = 10;
2639

2740
/**
2841
* A priority: <b>0</b> = low, <b>1</b> = medium, <b>2</b> = high
2942
*/
43+
@Column(name = "ld_prio")
3044
private int prio = 0;
3145

46+
@Column(name = "ld_confirmation")
3247
private int confirmation = 0; // 0 - false; 1 - true
3348

3449
/**
3550
* The date this message was last notified
3651
*/
52+
@Column(name = "ld_lastnotified")
3753
private Date lastNotified = null;
3854

55+
@Column(name = "ld_status", nullable = false)
3956
private int status = STATUS_NEW;
4057

4158
/**
4259
* The number of notification trials
4360
*/
61+
@Column(name = "ld_trials")
4462
private int trials = 0;
4563

4664
public SystemMessage() {

logicaldoc-core/src/main/java/com/logicaldoc/core/conversion/FormatConverterManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,7 @@ public void convertFile(File in, String inFilename, File out, String outFormat,
322322
history.setEvent(UserEvent.FILE_CONVERSION.toString());
323323
history.setFilename(FileUtil.getBaseName(inFilename) + "." + outFormat.toLowerCase());
324324
history.setFileSize(in.length());
325-
history.setFilenameOld(inFilename);
326-
history.setComment(String.format("%s -> %s", history.getFilenameOld(), history.getFilename()));
325+
history.setComment(String.format("%s -> %s", inFilename, history.getFilename()));
327326
history.setIp(session.getClient().getAddress());
328327

329328
UserHistoryDAO dao = Context.get(UserHistoryDAO.class);

0 commit comments

Comments
 (0)