Repository navigation
Expand file tree
/
Copy pathAddress.kt
More file actions
172 lines (164 loc) · 6.59 KB
/
Copy pathAddress.kt
File metadata and controls
172 lines (164 loc) · 6.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/////////////////////////////////////////////////////////////////////////////
//
// Project ProjectForge Community Edition
// www.projectforge.org
//
// Copyright (C) 2001-2026 Micromata GmbH, Germany (www.micromata.com)
//
// ProjectForge is dual-licensed.
//
// This community edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published
// by the Free Software Foundation; version 3 of the License.
//
// This community edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
// Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, see http://www.gnu.org/licenses/.
//
/////////////////////////////////////////////////////////////////////////////
package org.projectforge.rest.dto
import com.fasterxml.jackson.annotation.JsonProperty
import org.projectforge.business.address.*
import org.projectforge.framework.i18n.translate
import org.projectforge.framework.utils.LabelValueBean
import java.time.LocalDate
import java.util.*
class Address(
var contactStatus: ContactStatus? = null,
var addressStatus: AddressStatus? = null,
var uid: String? = null,
var name: String? = null,
/**
* Including formerly name (maiden name) if exists.
*/
var fullLastName: String? = null,
var firstName: String? = null,
var birthName: String? = null,
var form: FormOfAddress? = null,
var title: String? = null,
var positionText: String? = null,
var organization: String? = null,
var division: String? = null,
var businessPhone: String? = null,
var mobilePhone: String? = null,
var fax: String? = null,
var addressText: String? = null,
var addressText2: String? = null,
var zipCode: String? = null,
var city: String? = null,
var country: String? = null,
var state: String? = null,
var postalAddressText: String? = null,
var postalAddressText2: String? = null,
var postalZipCode: String? = null,
var postalCity: String? = null,
var postalCountry: String? = null,
var postalState: String? = null,
var email: String? = null,
var website: String? = null,
var communicationLanguage: Locale? = null,
var privatePhone: String? = null,
var privateMobilePhone: String? = null,
var privateAddressText: String? = null,
var privateAddressText2: String? = null,
var privateZipCode: String? = null,
var privateCity: String? = null,
var privateCountry: String? = null,
var privateState: String? = null,
var privateEmail: String? = null,
var publicKey: String? = null,
var fingerprint: String? = null,
var comment: String? = null,
var birthday: LocalDate? = null,
var imageData: ByteArray? = null,
var imageDataPreview: ByteArray? = null,
/**
* Frontend-only: Indicates that an image has been uploaded to the session (for new addresses).
* Used by CustomizedAddressImage to determine image source.
*/
var hasUploadedImage: Boolean = false,
/**
* Frontend-only: Data URL of the image for immediate display (from FileReader).
* Used by CustomizedAddressImage to show uploaded/imported images before save.
*/
var imageDataUrl: String? = null,
/**
* Frontend-only: Marks the image as pending deletion (will be deleted on form save).
* Allows Cancel button to restore the image.
*/
var imageDeleted: Boolean = false,
var instantMessaging: MutableList<LabelValueBean<InstantMessagingType, String>>? = null,
var addressbookList: MutableSet<Addressbook>? = null,
/**
* Is this address a personal favorite of the current logged-in user?
*/
var isFavoriteCard: Boolean = false,
/**
* Warning message for duplicate addresses (populated by watchFields).
*/
var duplicateWarning: String? = null,
/**
* Whether an image is stored for this address (`address/image/{id}`, `address/imagePreview/{id}`).
*/
var hasImage: Boolean = false,
/**
* Posted by the form of projectforge-next only, if it was opened for an entry of a running VCF import: the
* index of that entry, which a save marks as imported (see AddressSaveSupport.reconcileImport).
*/
var importIndex: Int? = null,
override var writeAccess: Boolean? = null,
override var deleteAccess: Boolean? = null,
) : BaseDTO<AddressDO>(), EntityAccessSupport {
@get:JsonProperty(access = JsonProperty.Access.READ_ONLY)
val contactStatusAsString: String?
get() {
contactStatus?.let { return translate(it.i18nKey) }
return null
}
@get:JsonProperty(access = JsonProperty.Access.READ_ONLY)
val addressStatusAsString: String?
get() {
addressStatus?.let { return translate(it.i18nKey) }
return null
}
override fun copyFrom(src: AddressDO) {
super.copyFrom(src)
if (AddressImageCache.instance.getImage(src.id) != null) {
imageData = byteArrayOf(1) // Marker for frontend for an available image.
hasImage = true
}
// For new addresses no cache entry exist.
val srcAddressbookList = AddressbookCache.instance.getAddressbooksForAddress(src) ?: src.addressbookList
if (!srcAddressbookList.isNullOrEmpty()) {
addressbookList = mutableSetOf()
srcAddressbookList.forEach { srcAddressbook ->
val addressbook = Addressbook()
addressbook.copyFromMinimal(srcAddressbook)
addressbook.title = srcAddressbook.title
addressbookList!!.add(addressbook)
}
}
fullLastName = src.fullLastName
firstName = src.firstName
organization = src.organization
}
override fun copyTo(dest: AddressDO) {
super.copyTo(dest)
if (!addressbookList.isNullOrEmpty()) {
addressbookList?.forEach { srcAddressbook ->
val addressbook = AddressbookDO()
srcAddressbook.copyTo(addressbook)
if (addressbook.title == null) {
// A reference by id, as the pickers of projectforge-next post it ({id, displayName}): the
// validation of the address checks its address books as well, which need their title.
addressbook.title = AddressbookCache.instance.getAddressbook(srcAddressbook.id)?.title
}
dest.add(addressbook)
}
}
}
}