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 640c7436
authored
Jun 03, 2014
by
Antti Tönkyrä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add horizon for network association
1 parent
4b6f3474
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
0 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/NetworkAssociationFacade.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBeanLocal.java
code/MoyaWeb/src/fi/codecrew/moya/rest/NetworkAssociationRestView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBean.java
View file @
640c743
...
@@ -281,4 +281,23 @@ public class NetworkAssociationBean implements NetworkAssociationBeanLocal {
...
@@ -281,4 +281,23 @@ public class NetworkAssociationBean implements NetworkAssociationBeanLocal {
if
(
na
.
size
()
>
0
)
return
na
.
get
(
0
);
if
(
na
.
size
()
>
0
)
return
na
.
get
(
0
);
else
return
null
;
else
return
null
;
}
}
@Override
@RolesAllowed
(
NetworkAssociationPermission
.
S_CAN_ADMINISTER_ASSOCIATIONS
)
public
List
<
NetworkAssociation
>
getActiveAssociationsByHorizon
(
Boolean
activate
,
String
horizon
)
{
if
(
activate
)
activatePendingAssociationsByHorizon
(
horizon
);
return
networkAssociationFacade
.
findByStatusAndHorizon
(
eventBean
.
getCurrentEvent
(),
NetworkAssociationStatus
.
ACTIVE
,
horizon
);
}
private
void
activatePendingAssociationsByHorizon
(
String
horizon
)
{
List
<
NetworkAssociation
>
netAssocs
=
networkAssociationFacade
.
findByStatusAndHorizon
(
eventBean
.
getCurrentEvent
(),
NetworkAssociationStatus
.
PENDING
,
horizon
);
for
(
NetworkAssociation
na
:
netAssocs
)
{
na
.
setStatus
(
NetworkAssociationStatus
.
ACTIVE
);
na
.
setModifyTime
(
Calendar
.
getInstance
());
}
}
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/NetworkAssociationFacade.java
View file @
640c743
...
@@ -100,4 +100,19 @@ public class NetworkAssociationFacade extends IntegerPkGenericFacade<NetworkAsso
...
@@ -100,4 +100,19 @@ public class NetworkAssociationFacade extends IntegerPkGenericFacade<NetworkAsso
return
getEm
().
createQuery
(
cq
).
getResultList
();
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
}
public
List
<
NetworkAssociation
>
findByStatusAndHorizon
(
LanEvent
event
,
NetworkAssociationStatus
status
,
String
horizon
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
NetworkAssociation
>
cq
=
cb
.
createQuery
(
NetworkAssociation
.
class
);
Root
<
NetworkAssociation
>
root
=
cq
.
from
(
NetworkAssociation
.
class
);
cq
.
where
(
cb
.
and
(
cb
.
equal
(
root
.
get
(
NetworkAssociation_
.
event
),
event
),
cb
.
equal
(
root
.
get
(
NetworkAssociation_
.
status
),
status
),
cb
.
like
(
root
.
get
(
NetworkAssociation_
.
ip
),
horizon
+
"%"
)
)
);
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
}
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBeanLocal.java
View file @
640c743
...
@@ -28,4 +28,7 @@ public interface NetworkAssociationBeanLocal {
...
@@ -28,4 +28,7 @@ public interface NetworkAssociationBeanLocal {
NetworkAssociation
tryAssociate
(
String
usercode
,
String
ip
,
String
mac
,
NetworkAssociation
tryAssociate
(
String
usercode
,
String
ip
,
String
mac
,
String
code
,
Boolean
codeRequired
)
throws
Exception
;
String
code
,
Boolean
codeRequired
)
throws
Exception
;
List
<
NetworkAssociation
>
getActiveAssociationsByHorizon
(
Boolean
activate
,
String
horizon
);
}
}
code/MoyaWeb/src/fi/codecrew/moya/rest/NetworkAssociationRestView.java
View file @
640c743
...
@@ -147,6 +147,33 @@ public class NetworkAssociationRestView {
...
@@ -147,6 +147,33 @@ public class NetworkAssociationRestView {
}
}
}
}
@GET
@Path
(
"/get_all/{horizon}/{activate}"
)
@Produces
({
MediaType
.
APPLICATION_JSON
})
public
NetworkAssociationResponseRoot
getAllByHorizon
(
@PathParam
(
"activate"
)
Boolean
activate
,
@PathParam
(
"horizon"
)
String
horizon
)
{
NetworkAssociationResponseRoot
resp
=
new
NetworkAssociationResponseRoot
();
try
{
if
(
activate
==
null
)
throw
new
Exception
(
"INVALID_PARAMETER_FOR_ACTIVATE"
);
List
<
NetworkAssociation
>
activeAssociations
=
networkAssociationBean
.
getActiveAssociationsByHorizon
(
activate
,
horizon
);
for
(
NetworkAssociation
na
:
activeAssociations
)
{
resp
.
getAdditions
().
add
(
new
NetworkAssociationActionPojo
(
na
.
getIP
(),
na
.
getMAC
()));
}
return
resp
;
}
catch
(
Exception
e
)
{
resp
.
getResult
().
setResultCode
(
0
);
resp
.
getResult
().
setMessage
(
e
.
getMessage
());
return
resp
;
}
}
@POST
@POST
@Path
(
"/get_status_by_ip_mac"
)
@Path
(
"/get_status_by_ip_mac"
)
@Produces
({
MediaType
.
APPLICATION_JSON
})
@Produces
({
MediaType
.
APPLICATION_JSON
})
...
...
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