Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Max Mecklin
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 27d59c15
authored
Dec 20, 2015
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
database and basic functionality
1 parent
d83e9d33
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
824 additions
and
10 deletions
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/HelpBeanLocal.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/HelpBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/HelpFacade.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/HelpTextFacade.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/HelpTextHistoryFacade.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Help.java
code/moya-database/src/main/java/fi/codecrew/moya/model/HelpText.java
code/moya-database/src/main/java/fi/codecrew/moya/model/HelpTextHistory.java
code/moya-database/src/main/resources/META-INF/persistence.xml
code/moya-web/src/main/java/fi/codecrew/moya/web/ValidLocale.java → code/moya-utils/src/main/java/fi/codecrew/moya/enums/ValidLocale.java
code/moya-web/WebContent/resources/cditools/help/helptool.xhtml
code/moya-web/WebContent/resources/templates/primelayout/template.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/web/LocaleSelectorView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/help/HelpView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/menu/MenuView.java
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/HelpBeanLocal.java
0 → 100644
View file @
27d59c1
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package
fi
.
codecrew
.
moya
.
beans
;
import
fi.codecrew.moya.model.Help
;
import
fi.codecrew.moya.model.HelpText
;
import
javax.ejb.Local
;
import
java.util.Locale
;
@Local
public
interface
HelpBeanLocal
{
HelpText
getHelpForPage
(
String
pagepath
,
Locale
locale
);
Help
findOrCreateHelp
(
String
pagepath
);
HelpText
saveOrCreate
(
HelpText
help
);
}
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
View file @
27d59c1
...
@@ -343,6 +343,54 @@ public class BootstrapBean implements BootstrapBeanLocal {
...
@@ -343,6 +343,54 @@ public class BootstrapBean implements BootstrapBeanLocal {
deleteMenu
(
"/useradmin/changePassword"
);
deleteMenu
(
"/useradmin/changePassword"
);
dbUpdates
.
add
(
new
String
[]
{
"CREATE TABLE helps (id SERIAL NOT NULL, path TEXT, meta json, PRIMARY KEY (id))"
,
"CREATE TABLE help_texts (id SERIAL NOT NULL, "
+
"title TEXT, "
+
"description TEXT, "
+
"locale TEXT, "
+
"meta json, "
+
"last_edit_time TIMESTAMPTZ NOT NULL, "
+
"users_id INTEGER NOT NULL, "
+
"helps_id INTEGER NOT NULL, "
+
"PRIMARY KEY (id))"
,
"ALTER TABLE help_texts "
+
"ADD CONSTRAINT FK_help_texts_users_id "
+
"FOREIGN KEY (users_id) REFERENCES users (id)"
,
"ALTER TABLE help_texts "
+
"ADD CONSTRAINT FK_help_texts_helps_id "
+
"FOREIGN KEY (helps_id) REFERENCES helps (id)"
,
"CREATE TABLE help_text_histories (id SERIAL NOT NULL, "
+
"title TEXT, "
+
"description TEXT, "
+
"meta json, "
+
"edit_time TIMESTAMPTZ NOT NULL, "
+
"help_texts_id INTEGER NOT NULL, "
+
"users_id INTEGER NOT NULL, "
+
"PRIMARY KEY (id))"
,
"ALTER TABLE help_text_histories "
+
"ADD CONSTRAINT FK_help_text_histories_help_texts_id "
+
"FOREIGN KEY (help_texts_id) REFERENCES help_texts (id)"
,
});
dbUpdates
.
add
(
new
String
[]
{
"ALTER TABLE help_texts DROP COLUMN users_id;"
,
"ALTER TABLE help_texts ADD COLUMN event_users_id INTEGER NOT NULL;"
,
"ALTER TABLE help_text_histories DROP COLUMN users_id;"
,
"ALTER TABLE help_text_histories ADD COLUMN event_users_id INTEGER NOT NULL;"
,
"ALTER TABLE help_texts "
+
"ADD CONSTRAINT FK_help_texts_event_users_id "
+
"FOREIGN KEY (event_users_id) REFERENCES event_users (id)"
,
"ALTER TABLE help_text_histories "
+
"ADD CONSTRAINT FK_help_text_histories_event_users_id "
+
"FOREIGN KEY (event_users_id) REFERENCES event_users (id)"
,
});
}
}
public
BootstrapBean
()
{
public
BootstrapBean
()
{
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/HelpBean.java
0 → 100644
View file @
27d59c1
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package
fi
.
codecrew
.
moya
.
beans
;
import
fi.codecrew.moya.enums.ValidLocale
;
import
fi.codecrew.moya.facade.HelpFacade
;
import
fi.codecrew.moya.facade.HelpTextFacade
;
import
fi.codecrew.moya.facade.HelpTextHistoryFacade
;
import
fi.codecrew.moya.model.Help
;
import
fi.codecrew.moya.model.HelpText
;
import
fi.codecrew.moya.model.HelpTextHistory
;
import
javax.ejb.EJB
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
java.util.Calendar
;
import
java.util.Locale
;
/**
* Session Bean implementation class SitePageBean
*/
@Stateless
@LocalBean
public
class
HelpBean
implements
HelpBeanLocal
{
@EJB
HelpFacade
helpFacade
;
@EJB
HelpTextFacade
helpTextFacade
;
@EJB
HelpTextHistoryFacade
helpTextHistoryFacade
;
@EJB
PermissionBean
permissionBean
;
/**
* Default constructor.
*/
public
HelpBean
()
{
// TODO Auto-generated constructor stub
}
/**
* Finds help for specific page on wanted locale.
*
* @param pagepath path or "key" of page
* @param locale Wanted locale
* @return Help for wanted locale, if there is no help for that locale return help on default locale (or null if there is no help for default locale)
*/
@Override
public
HelpText
getHelpForPage
(
String
pagepath
,
Locale
locale
)
{
ValidLocale
validLocale
=
ValidLocale
.
findFromLocale
(
locale
);
HelpText
help
=
helpTextFacade
.
find
(
pagepath
,
validLocale
);
if
(
help
==
null
&&
validLocale
!=
ValidLocale
.
getDefaultLocale
())
{
help
=
helpTextFacade
.
find
(
pagepath
,
ValidLocale
.
getDefaultLocale
());
}
return
help
;
}
@Override
public
Help
findOrCreateHelp
(
String
pagepath
)
{
Help
help
=
helpFacade
.
findByPath
(
pagepath
);
if
(
help
==
null
)
{
help
=
new
Help
(
pagepath
);
helpFacade
.
create
(
help
);
}
return
help
;
}
@Override
public
HelpText
saveOrCreate
(
HelpText
help
)
{
help
.
setLastEdited
(
Calendar
.
getInstance
().
getTime
());
help
.
setLastEditor
(
permissionBean
.
getCurrentUser
());
if
(
help
.
getId
()
==
null
)
{
helpTextFacade
.
create
(
help
);
}
else
{
helpTextFacade
.
merge
(
help
);
}
HelpTextHistory
history
=
new
HelpTextHistory
(
help
);
helpTextHistoryFacade
.
create
(
history
);
return
help
;
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/facade/HelpFacade.java
0 → 100644
View file @
27d59c1
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package
fi
.
codecrew
.
moya
.
facade
;
import
fi.codecrew.moya.model.Help
;
import
fi.codecrew.moya.model.Help_
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
javax.persistence.TypedQuery
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Root
;
/**
* Created by tuukka on 19/12/15.
*/
@Stateless
@LocalBean
public
class
HelpFacade
extends
IntegerPkGenericFacade
<
Help
>
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
HelpFacade
.
class
);
public
HelpFacade
()
{
super
(
Help
.
class
);
}
public
Help
findByPath
(
String
pagepath
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
Help
>
cq
=
cb
.
createQuery
(
Help
.
class
);
Root
<
Help
>
root
=
cq
.
from
(
Help
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
Help_
.
path
),
pagepath
));
TypedQuery
<
Help
>
query
=
getEm
().
createQuery
(
cq
);
query
.
setMaxResults
(
1
);
return
super
.
getSingleNullableResult
(
query
);
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/facade/HelpTextFacade.java
0 → 100644
View file @
27d59c1
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package
fi
.
codecrew
.
moya
.
facade
;
import
fi.codecrew.moya.enums.ValidLocale
;
import
fi.codecrew.moya.model.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
javax.persistence.TypedQuery
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Path
;
import
javax.persistence.criteria.Root
;
/**
* Created by tuukka on 19/12/15.
*/
@Stateless
@LocalBean
public
class
HelpTextFacade
extends
IntegerPkGenericFacade
<
HelpText
>
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
HelpTextFacade
.
class
);
public
HelpTextFacade
()
{
super
(
HelpText
.
class
);
}
public
HelpText
find
(
String
path
,
ValidLocale
locale
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
HelpText
>
cq
=
cb
.
createQuery
(
HelpText
.
class
);
Root
<
HelpText
>
root
=
cq
.
from
(
HelpText
.
class
);
cq
.
where
(
cb
.
and
(
cb
.
equal
(
root
.
get
(
HelpText_
.
help
).
get
(
Help_
.
path
),
path
),
cb
.
equal
(
root
.
get
(
HelpText_
.
locale
),
locale
))
);
TypedQuery
<
HelpText
>
query
=
getEm
().
createQuery
(
cq
);
query
.
setMaxResults
(
1
);
return
super
.
getSingleNullableResult
(
query
);
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/facade/HelpTextHistoryFacade.java
0 → 100644
View file @
27d59c1
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package
fi
.
codecrew
.
moya
.
facade
;
import
fi.codecrew.moya.model.HelpText
;
import
fi.codecrew.moya.model.HelpTextHistory
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
/**
* Created by tuukka on 19/12/15.
*/
@Stateless
@LocalBean
public
class
HelpTextHistoryFacade
extends
IntegerPkGenericFacade
<
HelpTextHistory
>
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
HelpTextHistoryFacade
.
class
);
public
HelpTextHistoryFacade
()
{
super
(
HelpTextHistory
.
class
);
}
}
code/moya-database/src/main/java/fi/codecrew/moya/model/Help.java
0 → 100644
View file @
27d59c1
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
fi
.
codecrew
.
moya
.
model
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
/**
* Group for lectures, so you can set limits how many of these the user can
* choose
*/
@Entity
@Table
(
name
=
"helps"
)
public
class
Help
extends
GenericEntity
implements
Cloneable
{
private
static
final
long
serialVersionUID
=
1L
;
@Column
(
name
=
"path"
)
private
String
path
;
public
Help
(
String
path
)
{
this
.
path
=
path
;
}
public
Help
()
{
}
public
String
getPath
()
{
return
path
;
}
public
void
setPath
(
String
path
)
{
this
.
path
=
path
;
}
}
code/moya-database/src/main/java/fi/codecrew/moya/model/HelpText.java
0 → 100644
View file @
27d59c1
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
fi
.
codecrew
.
moya
.
model
;
import
fi.codecrew.moya.enums.ValidLocale
;
import
javax.persistence.*
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Locale
;
/**
* Group for lectures, so you can set limits how many of these the user can
* choose
*/
@Entity
@Table
(
name
=
"help_texts"
)
public
class
HelpText
extends
GenericEntity
implements
Cloneable
{
private
static
final
long
serialVersionUID
=
1L
;
@Column
(
name
=
"title"
)
private
String
title
;
@Column
(
name
=
"description"
)
private
String
text
;
@ManyToOne
()
@JoinColumn
(
name
=
"helps_id"
,
nullable
=
false
)
private
Help
help
;
@Enumerated
(
EnumType
.
STRING
)
@Column
(
name
=
"locale"
)
private
ValidLocale
locale
;
@Temporal
(
TemporalType
.
TIMESTAMP
)
@Column
(
name
=
"last_edit_time"
)
private
Date
lastEdited
;
@ManyToOne
()
@JoinColumn
(
name
=
"event_users_id"
,
nullable
=
false
)
private
EventUser
lastEditor
;
public
HelpText
(
Help
help
,
ValidLocale
locale
)
{
this
.
help
=
help
;
this
.
locale
=
locale
;
}
public
HelpText
()
{
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getText
()
{
return
text
;
}
public
void
setText
(
String
text
)
{
this
.
text
=
text
;
}
public
Help
getHelp
()
{
return
help
;
}
public
void
setHelp
(
Help
help
)
{
this
.
help
=
help
;
}
public
ValidLocale
getLocale
()
{
return
locale
;
}
public
void
setLocale
(
ValidLocale
locale
)
{
this
.
locale
=
locale
;
}
public
Date
getLastEdited
()
{
return
lastEdited
;
}
public
void
setLastEdited
(
Date
lastEdited
)
{
this
.
lastEdited
=
lastEdited
;
}
public
EventUser
getLastEditor
()
{
return
lastEditor
;
}
public
void
setLastEditor
(
EventUser
lastEditor
)
{
this
.
lastEditor
=
lastEditor
;
}
}
code/moya-database/src/main/java/fi/codecrew/moya/model/HelpTextHistory.java
0 → 100644
View file @
27d59c1
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
fi
.
codecrew
.
moya
.
model
;
import
javax.persistence.*
;
import
java.util.Date
;
/**
* Group for lectures, so you can set limits how many of these the user can
* choose
*/
@Entity
@Table
(
name
=
"help_text_histories"
)
public
class
HelpTextHistory
extends
GenericEntity
implements
Cloneable
{
private
static
final
long
serialVersionUID
=
1L
;
@ManyToOne
()
@JoinColumn
(
name
=
"help_texts_id"
,
nullable
=
false
)
HelpText
helpText
;
@Column
(
name
=
"title"
)
private
String
title
;
@Column
(
name
=
"description"
)
private
String
text
;
@Temporal
(
TemporalType
.
TIMESTAMP
)
@Column
(
name
=
"edit_time"
)
private
Date
edited
;
@ManyToOne
()
@JoinColumn
(
name
=
"event_users_id"
,
nullable
=
false
)
private
EventUser
editor
;
public
HelpTextHistory
()
{
}
/**
* Create new history entity for specific helpText
* @param parent
*/
public
HelpTextHistory
(
HelpText
parent
)
{
this
.
title
=
parent
.
getTitle
();
this
.
text
=
parent
.
getText
();
this
.
edited
=
parent
.
getLastEdited
();
this
.
editor
=
parent
.
getLastEditor
();
this
.
helpText
=
parent
;
}
public
HelpText
getHelpText
()
{
return
helpText
;
}
public
void
setHelpText
(
HelpText
helpText
)
{
this
.
helpText
=
helpText
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getText
()
{
return
text
;
}
public
void
setText
(
String
text
)
{
this
.
text
=
text
;
}
public
Date
getEdited
()
{
return
edited
;
}
public
void
setEdited
(
Date
edited
)
{
this
.
edited
=
edited
;
}
public
EventUser
getEditor
()
{
return
editor
;
}
public
void
setEditor
(
EventUser
editor
)
{
this
.
editor
=
editor
;
}
}
code/moya-database/src/main/resources/META-INF/persistence.xml
View file @
27d59c1
...
@@ -8,14 +8,13 @@
...
@@ -8,14 +8,13 @@
<property
name=
"eclipselink.cache.size.default"
value=
"16384"
/>
<property
name=
"eclipselink.cache.size.default"
value=
"16384"
/>
<property
name=
"eclipselink.logging.logger"
value=
"ServerLogger"
/>
<property
name=
"eclipselink.logging.logger"
value=
"ServerLogger"
/>
<property
name=
"eclipselink.jdbc.uppercase-columns"
value=
"false"
/>
<property
name=
"eclipselink.jdbc.uppercase-columns"
value=
"false"
/>
<property
name=
"eclipselink.target-database"
<property
name=
"eclipselink.target-database"
value=
"fi.codecrew.moya.database.eclipselink.MoyaPostgreSQLPlatform"
/>
value=
"fi.codecrew.moya.database.eclipselink.MoyaPostgreSQLPlatform"
/>
<property
name=
"eclipselink.create-ddl-jdbc-file-name"
value=
"moyaCreateDDL.sql"
/>
<property
name=
"eclipselink.create-ddl-jdbc-file-name"
value=
"moyaCreateDDL.sql"
/>
<property
name=
"eclipselink.drop-ddl-jdbc-file-name"
value=
"moyaDropDDL.sql"
/>
<property
name=
"eclipselink.drop-ddl-jdbc-file-name"
value=
"moyaDropDDL.sql"
/>
<property
name=
"eclipselink.target-server"
value=
"Glassfish"
/>
<property
name=
"eclipselink.target-server"
value=
"Glassfish"
/>
<property
name=
"eclipselink.session.customizer"
<property
name=
"eclipselink.session.customizer"
value=
"fi.codecrew.moya.database.eclipselink.MoyaSessionCustomizer"
/>
value=
"fi.codecrew.moya.database.eclipselink.MoyaSessionCustomizer"
/>
<property
name=
"eclipselink.ddl-generation"
value=
"create-tables"
/>
<property
name=
"eclipselink.ddl-generation
"
value=
"none
"
/>
<property
name=
"eclipselink.ddl-generation
.output-mode"
value=
"sql-script
"
/>
</properties>
</properties>
</persistence-unit>
</persistence-unit>
...
...
code/moya-
web/src/main/java/fi/codecrew/moya/web
/ValidLocale.java
→
code/moya-
utils/src/main/java/fi/codecrew/moya/enums
/ValidLocale.java
View file @
27d59c1
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
* future versions of the Software.
* future versions of the Software.
*
*
*/
*/
package
fi
.
codecrew
.
moya
.
web
;
package
fi
.
codecrew
.
moya
.
enums
;
import
java.util.Locale
;
import
java.util.Locale
;
...
@@ -34,4 +34,19 @@ public enum ValidLocale {
...
@@ -34,4 +34,19 @@ public enum ValidLocale {
public
Locale
getLocale
()
{
public
Locale
getLocale
()
{
return
locale
;
return
locale
;
}
}
public
static
ValidLocale
getDefaultLocale
()
{
return
ValidLocale
.
ENGLISH
;
}
public
static
ValidLocale
findFromLocale
(
Locale
locale
)
{
for
(
ValidLocale
l
:
values
())
{
if
(
l
.
getLocale
().
equals
(
locale
))
{
return
l
;
}
}
return
ValidLocale
.
getDefaultLocale
();
}
}
}
\ No newline at end of file
code/moya-web/WebContent/resources/cditools/help/helptool.xhtml
0 → 100644
View file @
27d59c1
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
xmlns:p=
"http://primefaces.org/ui"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<b><h:outputText
value=
"#{helpView.helpTitle}"
escape=
"false"
/></b><br
/>
<h:outputText
value=
"#{helpView.helpText}"
escape=
"false"
/><br
/>
<h:form>
<p:inputText
value=
"#{helpView.helpTitle}"
/><br
/>
<p:inputTextarea
value=
"#{helpView.helpText}"
/><br
/>
<p:commandButton
actionListener=
"#{helpView.saveHelpText}"
/>
</h:form>
</composite:implementation>
</html>
code/moya-web/WebContent/resources/templates/primelayout/template.xhtml
View file @
27d59c1
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<!DOCTYPE html>
<html
class=
"no-js"
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:tools=
"http://java.sun.com/jsf/composite/cditools"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
<html
class=
"no-js"
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:tools=
"http://java.sun.com/jsf/composite/cditools"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:p=
"http://primefaces.org/ui"
>
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:p=
"http://primefaces.org/ui"
xmlns:help=
"http://java.sun.com/jsf/composite/cditools/help"
>
<f:view
contentType=
"text/html"
locale=
"#{sessionHandler.locale}"
>
<f:view
contentType=
"text/html"
locale=
"#{sessionHandler.locale}"
>
...
@@ -48,7 +50,9 @@
...
@@ -48,7 +50,9 @@
<p:dialog
widgetVar=
"keepAliveDialog"
showEffect=
"fade"
hideEffect=
"explode"
header=
"#{i18n['template.keepaliveError.title']}"
modal=
"true"
>
<p:dialog
widgetVar=
"keepAliveDialog"
showEffect=
"fade"
hideEffect=
"explode"
header=
"#{i18n['template.keepaliveError.title']}"
modal=
"true"
>
<br
/>
#{i18n['template.keepaliveError']}
<br
/><br
/>
<br
/>
#{i18n['template.keepaliveError']}
<br
/><br
/>
<p:commandButton
value=
"OK"
type=
"button"
styleClass=
"ui-confirmdialog-yes"
icon=
"ui-icon-check"
onclick=
"location.reload();"
/>
<h:form>
<p:commandButton
value=
"OK"
type=
"button"
styleClass=
"ui-confirmdialog-yes"
icon=
"ui-icon-check"
onclick=
"location.reload();"
/>
</h:form>
</p:dialog>
</p:dialog>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
...
@@ -217,6 +221,10 @@
...
@@ -217,6 +221,10 @@
</p:layoutUnit>
</p:layoutUnit>
<p:layoutUnit
position=
"east"
resizable=
"true"
>
<help:helptool
/>
</p:layoutUnit>
<p:layoutUnit
position=
"south"
size=
"30"
>
<p:layoutUnit
position=
"south"
size=
"30"
>
<footer
class=
"bgColor1"
>
<footer
class=
"bgColor1"
>
<h:outputText
id=
"cdiloop"
value=
"#{conversationKeepaliveView.date}"
>
<h:outputText
id=
"cdiloop"
value=
"#{conversationKeepaliveView.date}"
>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/LocaleSelectorView.java
View file @
27d59c1
...
@@ -22,6 +22,7 @@ import javax.enterprise.context.RequestScoped;
...
@@ -22,6 +22,7 @@ import javax.enterprise.context.RequestScoped;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
fi.codecrew.moya.enums.ValidLocale
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/help/HelpView.java
0 → 100644
View file @
27d59c1
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
help
;
import
fi.codecrew.moya.beans.HelpBeanLocal
;
import
fi.codecrew.moya.enums.ValidLocale
;
import
fi.codecrew.moya.handler.SessionStore
;
import
fi.codecrew.moya.model.Help
;
import
fi.codecrew.moya.model.HelpText
;
import
fi.codecrew.moya.web.helper.LayoutView
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
/**
* Created by tuukka on 19/12/15.
*/
@Named
@RequestScoped
public
class
HelpView
{
// layoutview.getPagepath()
@Inject
LayoutView
layoutView
;
@EJB
HelpBeanLocal
helpBean
;
String
helpTitle
=
null
;
String
helpText
=
null
;
@Inject
private
transient
SessionStore
sessionstore
;
public
void
populateHelpText
()
{
HelpText
help
=
helpBean
.
getHelpForPage
(
layoutView
.
getPagepath
(),
sessionstore
.
getLocale
());
if
(
help
==
null
)
{
helpTitle
=
helpText
=
""
;
}
else
{
helpTitle
=
help
.
getTitle
();
helpText
=
help
.
getText
();
}
}
public
void
saveHelpText
()
{
if
(
helpText
==
null
||
helpText
.
trim
().
isEmpty
())
{
// todo: errormessage
return
;
}
HelpText
help
=
helpBean
.
getHelpForPage
(
layoutView
.
getPagepath
(),
sessionstore
.
getLocale
());
if
(
help
==
null
)
{
help
=
new
HelpText
(
helpBean
.
findOrCreateHelp
(
layoutView
.
getPagepath
()),
ValidLocale
.
findFromLocale
(
sessionstore
.
getLocale
()));
}
help
.
setText
(
getHelpText
());
help
.
setTitle
(
getHelpTitle
());
helpBean
.
saveOrCreate
(
help
);
}
public
String
getHelpTitle
()
{
if
(
helpTitle
==
null
)
{
populateHelpText
();
}
return
helpTitle
;
}
public
void
setHelpTitle
(
String
helpTitle
)
{
this
.
helpTitle
=
helpTitle
;
}
public
void
setHelpText
(
String
helpText
)
{
this
.
helpText
=
helpText
;
}
public
String
getHelpText
()
{
return
this
.
helpText
;
}
}
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/menu/MenuView.java
View file @
27d59c1
...
@@ -77,8 +77,6 @@ public class MenuView {
...
@@ -77,8 +77,6 @@ public class MenuView {
public
List
<
PageContent
>
getPagecontent
(
String
pagekey
)
public
List
<
PageContent
>
getPagecontent
(
String
pagekey
)
{
{
String
key
=
new
StringBuilder
(
layoutview
.
getPagepath
()).
append
(
":"
).
append
(
pagekey
).
toString
();
String
key
=
new
StringBuilder
(
layoutview
.
getPagepath
()).
append
(
":"
).
append
(
pagekey
).
toString
();
// Removed by tkfftk, enought is enought
// logger.debug("Getting pagecontent for key {}. Matches: {}", key, contents.containsKey(key));
if
(!
contents
.
containsKey
(
key
))
{
if
(!
contents
.
containsKey
(
key
))
{
contents
.
put
(
key
,
pagebean
.
findContentsForUser
(
key
,
sessionstore
.
getLocale
()));
contents
.
put
(
key
,
pagebean
.
findContentsForUser
(
key
,
sessionstore
.
getLocale
()));
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment