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 525c7345
authored
Jun 01, 2014
by
Antti Tönkyrä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
functions to get user info by ip address & get all users
1 parent
b3c51b46
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
190 additions
and
0 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBean.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBeanLocal.java
code/MoyaWeb/src/fi/codecrew/moya/rest/NetworkAssociationRestView.java
code/MoyaWeb/src/fi/codecrew/moya/rest/pojo/NetworkAssociationInfoPojo.java
code/MoyaWeb/src/fi/codecrew/moya/rest/pojo/NetworkAssociationInfoResponseRoot.java
code/MoyaWeb/src/fi/codecrew/moya/rest/pojo/NetworkAssociationInfolistResponseRoot.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBean.java
View file @
525c734
...
...
@@ -249,5 +249,17 @@ public class NetworkAssociationBean implements NetworkAssociationBeanLocal {
private
Place
resolvePlaceFromCode
(
String
code
)
{
if
(
code
==
null
)
return
null
;
return
barcodeBean
.
getPlaceFromTextCode
(
code
);
}
@Override
@RolesAllowed
(
NetworkAssociationPermission
.
S_CAN_ADMINISTER_ASSOCIATIONS
)
public
NetworkAssociation
getActiveAssociationByIP
(
String
ipAddress
)
{
List
<
NetworkAssociation
>
na
=
this
.
networkAssociationFacade
.
findActiveAssociationsByIP
(
eventBean
.
getCurrentEvent
(),
ipAddress
);
if
(
na
.
size
()
>
0
)
return
na
.
get
(
0
);
else
return
null
;
}
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBeanLocal.java
View file @
525c734
...
...
@@ -23,4 +23,6 @@ public interface NetworkAssociationBeanLocal {
void
dropAssociationById
(
Integer
associd
);
NetworkAssociation
getActiveAssociationByIP
(
String
ipAddress
);
}
code/MoyaWeb/src/fi/codecrew/moya/rest/NetworkAssociationRestView.java
View file @
525c734
...
...
@@ -16,6 +16,9 @@ import fi.codecrew.moya.beans.NetworkAssociationBeanLocal;
import
fi.codecrew.moya.enums.NetworkAssociationStatus
;
import
fi.codecrew.moya.model.NetworkAssociation
;
import
fi.codecrew.moya.rest.pojo.NetworkAssociationActionPojo
;
import
fi.codecrew.moya.rest.pojo.NetworkAssociationInfoPojo
;
import
fi.codecrew.moya.rest.pojo.NetworkAssociationInfoResponseRoot
;
import
fi.codecrew.moya.rest.pojo.NetworkAssociationInfolistResponseRoot
;
import
fi.codecrew.moya.rest.pojo.NetworkAssociationResponseRoot
;
@RequestScoped
...
...
@@ -58,6 +61,36 @@ public class NetworkAssociationRestView {
}
@GET
@Path
(
"/get_association_infos"
)
@Produces
({
MediaType
.
APPLICATION_JSON
})
public
NetworkAssociationInfolistResponseRoot
getAssociationInfos
()
{
NetworkAssociationInfolistResponseRoot
nairr
=
new
NetworkAssociationInfolistResponseRoot
();
for
(
NetworkAssociation
na
:
networkAssociationBean
.
getActiveAssociations
(
false
))
{
nairr
.
getAssociations
().
add
(
new
NetworkAssociationInfoPojo
(
na
));
}
return
nairr
;
}
@GET
@Path
(
"/get_association_info_by_ip/{ipAddress}"
)
@Produces
({
MediaType
.
APPLICATION_JSON
})
public
NetworkAssociationInfoResponseRoot
getAssociationInfos
(
@PathParam
(
"ipAddress"
)
String
ipAddress
)
{
NetworkAssociation
na
=
networkAssociationBean
.
getActiveAssociationByIP
(
ipAddress
);
NetworkAssociationInfoResponseRoot
nairr
;
if
(
na
!=
null
)
{
nairr
=
new
NetworkAssociationInfoResponseRoot
(
new
NetworkAssociationInfoPojo
(
na
)
);
}
else
{
nairr
=
new
NetworkAssociationInfoResponseRoot
();
}
return
nairr
;
}
@GET
@Path
(
"/get_all/{activate}"
)
@Produces
({
MediaType
.
APPLICATION_JSON
})
public
NetworkAssociationResponseRoot
getAll
(
...
...
@@ -65,6 +98,7 @@ public class NetworkAssociationRestView {
)
{
NetworkAssociationResponseRoot
resp
=
new
NetworkAssociationResponseRoot
();
try
{
if
(
activate
==
null
)
throw
new
Exception
(
"INVALID_PARAMETER_FOR_ACTIVATE"
);
...
...
code/MoyaWeb/src/fi/codecrew/moya/rest/pojo/NetworkAssociationInfoPojo.java
0 → 100644
View file @
525c734
package
fi
.
codecrew
.
moya
.
rest
.
pojo
;
import
java.util.Calendar
;
import
javax.xml.bind.annotation.XmlElement
;
import
fi.codecrew.moya.model.NetworkAssociation
;
public
class
NetworkAssociationInfoPojo
{
private
String
createTime
;
private
String
modifyTime
;
private
String
ipAddress
;
private
String
macAddress
;
private
Integer
placeId
;
private
Integer
eventuserId
;
public
NetworkAssociationInfoPojo
(
NetworkAssociation
na
)
{
this
.
createTime
=
na
.
getCreateTime
().
getTime
().
toString
();
this
.
modifyTime
=
na
.
getModifyTime
().
getTime
().
toString
();
this
.
ipAddress
=
na
.
getIP
();
this
.
macAddress
=
na
.
getMAC
();
if
(
na
.
getPlace
()
!=
null
)
this
.
placeId
=
na
.
getPlace
().
getId
();
else
this
.
placeId
=
null
;
this
.
eventuserId
=
na
.
getEventUser
().
getId
();
}
public
NetworkAssociationInfoPojo
()
{
this
.
createTime
=
null
;
this
.
modifyTime
=
null
;
this
.
ipAddress
=
null
;
this
.
macAddress
=
null
;
this
.
placeId
=
null
;
this
.
eventuserId
=
null
;
}
@XmlElement
(
name
=
"createTime"
)
public
String
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
String
createTime
)
{
this
.
createTime
=
createTime
;
}
@XmlElement
(
name
=
"modifyTime"
)
public
String
getModifyTime
()
{
return
modifyTime
;
}
public
void
setModifyTime
(
String
modifyTime
)
{
this
.
modifyTime
=
modifyTime
;
}
@XmlElement
(
name
=
"ipAddress"
)
public
String
getIpAddress
()
{
return
ipAddress
;
}
public
void
setIpAddress
(
String
ipAddress
)
{
this
.
ipAddress
=
ipAddress
;
}
@XmlElement
(
name
=
"macAddress"
)
public
String
getMacAddress
()
{
return
macAddress
;
}
public
void
setMacAddress
(
String
macAddress
)
{
this
.
macAddress
=
macAddress
;
}
@XmlElement
(
name
=
"placeId"
)
public
Integer
getPlaceId
()
{
return
placeId
;
}
public
void
setPlaceId
(
Integer
placeId
)
{
this
.
placeId
=
placeId
;
}
@XmlElement
(
name
=
"eventuserId"
)
public
Integer
getEventuserId
()
{
return
eventuserId
;
}
public
void
setEventuserId
(
Integer
eventuserId
)
{
this
.
eventuserId
=
eventuserId
;
}
}
code/MoyaWeb/src/fi/codecrew/moya/rest/pojo/NetworkAssociationInfoResponseRoot.java
0 → 100644
View file @
525c734
package
fi
.
codecrew
.
moya
.
rest
.
pojo
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
public
class
NetworkAssociationInfoResponseRoot
{
private
NetworkAssociationInfoPojo
association
;
public
NetworkAssociationInfoResponseRoot
(
NetworkAssociationInfoPojo
naip
)
{
this
.
association
=
naip
;
}
public
NetworkAssociationInfoResponseRoot
()
{
this
.
association
=
null
;
}
public
NetworkAssociationInfoPojo
getAssociation
()
{
return
association
;
}
public
void
setAssociation
(
NetworkAssociationInfoPojo
association
)
{
this
.
association
=
association
;
}
}
code/MoyaWeb/src/fi/codecrew/moya/rest/pojo/NetworkAssociationInfolistResponseRoot.java
0 → 100644
View file @
525c734
package
fi
.
codecrew
.
moya
.
rest
.
pojo
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
public
class
NetworkAssociationInfolistResponseRoot
{
private
List
<
NetworkAssociationInfoPojo
>
associations
;
public
NetworkAssociationInfolistResponseRoot
()
{
this
.
associations
=
new
ArrayList
<>();
}
public
List
<
NetworkAssociationInfoPojo
>
getAssociations
()
{
return
associations
;
}
public
void
setAssociations
(
List
<
NetworkAssociationInfoPojo
>
associations
)
{
this
.
associations
=
associations
;
}
}
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