Commit 8770daf1 by Tuomas Riihimäki

Fix Event creation error

Also fix updating event properties on when creating new properties.
1 parent 44b77763
......@@ -29,7 +29,7 @@ import fi.codecrew.moya.model.User;
@Local
public interface EventOrganiserBeanLocal {
void save(EventOrganiser eventorg);
EventOrganiser save(EventOrganiser eventorg);
List<EventOrganiser> getEventOrganisers();
......
......@@ -48,6 +48,7 @@ import fi.codecrew.moya.model.LanEventPrivateProperty;
import fi.codecrew.moya.model.LanEventPrivatePropertyKey;
import fi.codecrew.moya.model.LanEventProperty;
import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
/**
* Session Bean implementation class EventBean
......@@ -83,6 +84,8 @@ public class EventBean implements EventBeanLocal {
private LanEventPropertyFacade eventPropertyFacade;
@EJB
private LanEventPrivatePropertyFacade eventPrivatePropertyFacade;
@EJB
private LoggingBeanLocal logbean;
@Override
public LanEvent getEventByHostname(String hostname) {
......@@ -163,7 +166,7 @@ public class EventBean implements EventBeanLocal {
}
@Override
@RolesAllowed({ SpecialPermission.S_SUPERADMIN })
@RolesAllowed({ SpecialPermission.S_SUPERADMIN, EventPermission.S_MANAGE_EVENT })
public void create(LanEvent event) {
eventFacade.create(event);
......@@ -206,8 +209,6 @@ public class EventBean implements EventBeanLocal {
return eventPropertyFacade.find(getCurrentEvent(), property);
}
@Override
public long getPropertyLong(LanEventPropertyKey property)
{
......@@ -242,7 +243,7 @@ public class EventBean implements EventBeanLocal {
if (retProp == null) {
String def = property.getDefaultvalue();
if(def != null && !def.trim().isEmpty() && def.trim().equals("1"))
if (def != null && !def.trim().isEmpty() && def.trim().equals("1"))
ret = true;
} else {
......@@ -258,20 +259,18 @@ public class EventBean implements EventBeanLocal {
LanEventProperty ret = null;
logger.info("Saving property {}, eventorg {}, key {}", new Object[] { property.getEvent(), property.getEventorg(), property.getKey() });
if (property.getId() == null)
{
if (property.getId() == null) {
ret = property;
// eventPropertyFacade.create(property);
LanEvent event = eventFacade.reload(property.getEvent());
if (event.getProperties() == null)
{
property.setEvent(event);
if (event.getProperties() == null) {
event.setProperties(new ArrayList<LanEventProperty>());
}
event.getProperties().add(property);
}
else
{
else {
ret = eventPropertyFacade.merge(property);
}
return ret;
......@@ -289,11 +288,9 @@ public class EventBean implements EventBeanLocal {
public LanEventPrivateProperty saveOrCreatePrivateProperty(LanEventPrivateProperty privateProperty) {
LanEventPrivateProperty ret = null;
logger.info("Saving property {}, eventorg {}, key {}", new Object[] { privateProperty.getEvent(), privateProperty.getEventorg(), privateProperty.getKey() });
if (privateProperty.getId() == null)
{
if (privateProperty.getId() == null) {
ret = privateProperty;
// eventPropertyFacade.create(property);
eventPrivatePropertyFacade.create(privateProperty);
} else {
ret = eventPrivatePropertyFacade.merge(privateProperty);
......@@ -316,16 +313,16 @@ public class EventBean implements EventBeanLocal {
public LanEvent deleteProperty(LanEventProperty property) {
property = eventPropertyFacade.reload(property);
LanEvent event = property.getEvent();
eventPropertyFacade.remove(property);
event.getProperties().remove(property);
eventPropertyFacade.refresh(property);
return event;
}
@Override
@RolesAllowed({ EventPermission.S_MANAGE_PRIVATE_PROPERTIES, EventPermission.S_MANAGE_EVENT })
public LanEvent deletePrivateProperty(LanEventPrivateProperty property) {
LanEventPrivateProperty prop = eventPrivatePropertyFacade.reload(property);
LanEvent event = prop.getEvent();
property = eventPrivatePropertyFacade.reload(property);
LanEvent event = property.getEvent();
eventPrivatePropertyFacade.remove(property);
return event;
}
......@@ -337,21 +334,3 @@ public class EventBean implements EventBeanLocal {
}
}
......@@ -60,8 +60,8 @@ public class EventOrganiserBean implements EventOrganiserBeanLocal {
}
@Override
public void save(EventOrganiser eventorg) {
eventorgfacade.merge(eventorg);
public EventOrganiser save(EventOrganiser eventorg) {
return eventorgfacade.merge(eventorg);
}
@Override
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!