Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Catalog
Genesys Catalog Server
Commits
82e60a65
Commit
82e60a65
authored
Jan 21, 2018
by
Matija Obreza
Browse files
Added Partner.countryCodes
parent
ae45bc18
Changes
6
Hide whitespace changes
Inline
Side-by-side
genesys-catalog-core/src/main/java/org/genesys/catalog/service/impl/PartnerServiceImpl.java
View file @
82e60a65
...
...
@@ -189,6 +189,10 @@ public class PartnerServiceImpl implements PartnerService, InitializingBean {
target
.
setWiewsCodes
(
new
HashSet
<>());
if
(
source
.
getWiewsCodes
()
!=
null
)
target
.
getWiewsCodes
().
addAll
(
source
.
getWiewsCodes
());
target
.
setCountryCodes
(
new
HashSet
<>());
if
(
source
.
getCountryCodes
()
!=
null
)
target
.
getCountryCodes
().
addAll
(
source
.
getCountryCodes
());
}
/**
...
...
@@ -210,8 +214,15 @@ public class PartnerServiceImpl implements PartnerService, InitializingBean {
*/
protected
Partner
lazyLoad
(
final
Partner
partner
)
{
if
(
partner
!=
null
)
{
partner
.
getUrls
().
size
();
partner
.
getWiewsCodes
().
size
();
if
(
partner
.
getUrls
()
!=
null
)
{
partner
.
getUrls
().
size
();
}
if
(
partner
.
getWiewsCodes
()
!=
null
)
{
partner
.
getWiewsCodes
().
size
();
}
if
(
partner
.
getCountryCodes
()
!=
null
)
{
partner
.
getCountryCodes
().
size
();
}
}
return
partner
;
}
...
...
genesys-catalog-core/src/main/java/org/genesys/common/model/Partner.java
View file @
82e60a65
...
...
@@ -31,6 +31,7 @@ import javax.persistence.JoinColumn;
import
javax.persistence.Lob
;
import
javax.persistence.OneToMany
;
import
javax.persistence.Table
;
import
javax.persistence.UniqueConstraint
;
import
org.genesys.blocks.model.UuidModel
;
import
org.genesys.blocks.security.model.AclAwareModel
;
...
...
@@ -80,6 +81,11 @@ public class Partner extends UuidModel implements AclAwareModel {
@Column
(
name
=
"wiews"
)
private
Set
<
String
>
wiewsCodes
;
@ElementCollection
@CollectionTable
(
name
=
"PartnerCountry"
,
joinColumns
=
@JoinColumn
(
name
=
"partnerId"
),
uniqueConstraints
=
{
@UniqueConstraint
(
columnNames
=
{
"partnerId"
,
"code"
})
})
@Column
(
name
=
"code"
,
length
=
3
,
nullable
=
false
)
private
Set
<
String
>
countryCodes
;
@JsonIgnore
@OneToMany
(
cascade
=
{
CascadeType
.
REMOVE
},
orphanRemoval
=
true
,
mappedBy
=
"owner"
,
fetch
=
FetchType
.
LAZY
)
private
List
<
Descriptor
>
descriptors
;
...
...
@@ -104,7 +110,8 @@ public class Partner extends UuidModel implements AclAwareModel {
* @param partner the partner
*/
public
Partner
(
final
Partner
partner
)
{
this
(
partner
.
getShortName
(),
partner
.
getName
(),
partner
.
getUrls
(),
partner
.
getWiewsCodes
(),
partner
.
getDescriptors
(),
partner
.
getVocabularies
(),
partner
.
getDescriptorList
());
this
(
partner
.
getShortName
(),
partner
.
getName
(),
partner
.
getUrls
(),
partner
.
getWiewsCodes
(),
partner
.
getDescriptors
(),
partner
.
getVocabularies
(),
partner
.
getDescriptorList
());
}
/**
...
...
@@ -122,9 +129,9 @@ public class Partner extends UuidModel implements AclAwareModel {
final
List
<
ControlledVocabulary
>
vocabularies
,
final
List
<
DescriptorList
>
descriptorList
)
{
this
.
shortName
=
shortName
;
this
.
name
=
name
;
if
(
urls
!=
null
)
if
(
urls
!=
null
)
this
.
urls
=
new
HashSet
<>(
urls
);
if
(
wiewsCodes
!=
null
)
if
(
wiewsCodes
!=
null
)
this
.
wiewsCodes
=
new
HashSet
<>(
wiewsCodes
);
this
.
descriptors
=
descriptors
;
this
.
vocabularies
=
vocabularies
;
...
...
@@ -221,6 +228,24 @@ public class Partner extends UuidModel implements AclAwareModel {
this
.
wiewsCodes
=
wiewsCodes
;
}
/**
* Gets the country codes.
*
* @return the country codes
*/
public
Set
<
String
>
getCountryCodes
()
{
return
countryCodes
;
}
/**
* Sets the country codes.
*
* @param countryCodes the new country codes
*/
public
void
setCountryCodes
(
Set
<
String
>
countryCodes
)
{
this
.
countryCodes
=
countryCodes
;
}
/**
* Gets the descriptors.
*
...
...
genesys-catalog-core/src/test/java/org/genesys/catalog/service/PartnerServiceTest.java
View file @
82e60a65
...
...
@@ -254,4 +254,29 @@ public class PartnerServiceTest extends CatalogServiceTest {
assertThat
(
result
.
getUuid
(),
is
(
uuid
));
}
/**
* I need to update Partner country codes
*/
@Test
public
void
testUpdatePartnerCountries
()
throws
MalformedURLException
{
Partner
input
=
new
Partner
();
input
.
setName
(
PARTNER_1
);
input
.
setShortName
(
PARTNER_ACRONYM_1
);
Partner
result
=
partnerService
.
createPartner
(
input
);
UUID
uuid
=
result
.
getUuid
();
// update
result
.
setCountryCodes
(
Sets
.
newHashSet
(
"NGA"
,
"DEU"
,
"SVN"
));
result
=
partnerService
.
updatePartner
(
result
);
assertThat
(
result
.
getUuid
(),
is
(
uuid
));
assertThat
(
result
.
getCountryCodes
(),
containsInAnyOrder
(
"NGA"
,
"DEU"
,
"SVN"
));
result
.
setCountryCodes
(
Sets
.
newHashSet
(
"BAR"
,
"FOO"
));
result
=
partnerService
.
updatePartner
(
result
);
assertThat
(
result
.
getCountryCodes
(),
containsInAnyOrder
(
"FOO"
,
"BAR"
));
}
}
genesys-catalog-server/pom.xml
View file @
82e60a65
...
...
@@ -82,9 +82,9 @@
<outputChangeLogFile>
${project.basedir}/src/main/resources/liquibase/liquibase-initial.yml
</outputChangeLogFile>
<diffChangeLogFile>
${project.basedir}/src/main/resources/liquibase/liquibase-changeLog-diff.yml
</diffChangeLogFile>
<driver>
com.mysql.jdbc.Driver
</driver>
<url>
jdbc:mysql://localhost/catalog
production
?useUnicode=true
&
characterEncoding=UTF-8
&
useFastDateParsing=false
&
useSSL=false
</url>
<url>
jdbc:mysql://localhost/catalog?useUnicode=true
&
characterEncoding=UTF-8
&
useFastDateParsing=false
&
useSSL=false
</url>
<username>
root
</username>
<referenceUrl>
jdbc:mysql://localhost/catalog?useUnicode=true
&
characterEncoding=UTF-8
&
useFastDateParsing=false
&
useSSL=false
</referenceUrl>
<referenceUrl>
jdbc:mysql://localhost/catalog
auto
?useUnicode=true
&
characterEncoding=UTF-8
&
useFastDateParsing=false
&
useSSL=false
</referenceUrl>
<referenceUsername>
root
</referenceUsername>
</configuration>
</execution>
...
...
genesys-catalog-server/src/main/resources/application.properties
View file @
82e60a65
...
...
@@ -10,7 +10,15 @@ base.url=//${host.nameAndPort}
cdn.servers
=
${base.url}
# Database connection
## Uncomment to generate schema in catalogauto
#db.url=jdbc:mysql://localhost/catalogauto?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false&useSSL=false
#db.updateSchema=true
# WARNING: Make sure liquibase-changeLog.yml contains required changes. Do not rely on db.updateSchema!
db.url
=
jdbc:mysql://localhost/catalog?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false&useSSL=false
db.updateSchema
=
false
db.driverClassName
=
com.mysql.jdbc.Driver
db.username
=
root
db.password
=
...
...
@@ -20,8 +28,6 @@ db.showSql=false
db.pool.initialSize
=
5
db.pool.maxActive
=
10
# WARNING: Make sure liquibase-changeLog.yml contains required changes. Do not rely on db.updateSchema!
db.updateSchema
=
false
default.admin.email
=
admin@example.com
default.admin.password
=
Admin123!
...
...
genesys-catalog-server/src/main/resources/liquibase/liquibase-changeLog.yml
View file @
82e60a65
...
...
@@ -3127,3 +3127,36 @@ databaseChangeLog:
name
:
publisher
type
:
VARCHAR(200)
tableName
:
controlled_vocabulary
-
changeSet
:
id
:
1516559954396-1
author
:
mobreza (generated)
comment
:
Added Partner.countryCodes
changes
:
-
createTable
:
columns
:
-
column
:
constraints
:
nullable
:
false
name
:
partner_id
type
:
BIGINT
-
column
:
constraints
:
nullable
:
false
name
:
code
type
:
VARCHAR(3)
tableName
:
partner_country
-
addPrimaryKey
:
columnNames
:
partner_id, code
constraintName
:
PRIMARY
tableName
:
partner_country
-
addForeignKeyConstraint
:
baseColumnNames
:
partner_id
baseTableName
:
partner_country
constraintName
:
FK_ik4r4qhadosm2889cupij8y3m
deferrable
:
false
initiallyDeferred
:
false
onDelete
:
NO ACTION
onUpdate
:
NO ACTION
referencedColumnNames
:
id
referencedTableName
:
partner
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment