From: <pka...@us...> - 2009-07-17 14:21:59
|
Revision: 341 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=341&view=rev Author: pkasprzak Date: 2009-07-17 14:21:51 +0000 (Fri, 17 Jul 2009) Log Message: ----------- * Support for getOutboundClients() in configuration manager (+ WSDL / XSD) * Set jndi-name for session beans Modified Paths: -------------- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerImpl.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/IdentityManagerImpl.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManagerImpl.java Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerImpl.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerImpl.java 2009-07-17 14:09:03 UTC (rev 340) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerImpl.java 2009-07-17 14:21:51 UTC (rev 341) @@ -13,7 +13,7 @@ * * @author pete */ -@Stateless +@Stateless(mappedName = "cse/DependencyManager") public class DependencyManagerImpl implements DependencyManagerRemote, DependencyManager { @PersistenceContext Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java 2009-07-17 14:09:03 UTC (rev 340) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java 2009-07-17 14:21:51 UTC (rev 341) @@ -15,7 +15,7 @@ * * @author pete */ -@Stateless +@Stateless(mappedName = "cse/EntityManager") public class EntityManagerImpl implements EntityManagerRemote, EntityManager { @PersistenceContext Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/IdentityManagerImpl.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/IdentityManagerImpl.java 2009-07-17 14:09:03 UTC (rev 340) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/IdentityManagerImpl.java 2009-07-17 14:21:51 UTC (rev 341) @@ -10,7 +10,7 @@ * * @author pete */ -@Stateless +@Stateless(mappedName = "cse/IdentityManager") public class IdentityManagerImpl implements IdentityManagerRemote, IdentityManager { @PersistenceContext Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManagerImpl.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManagerImpl.java 2009-07-17 14:09:03 UTC (rev 340) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManagerImpl.java 2009-07-17 14:21:51 UTC (rev 341) @@ -14,7 +14,7 @@ * * @author pete */ -@Stateless +@Stateless(mappedName = "cse/RelationManager") public class RelationManagerImpl implements RelationManagerRemote, RelationManager { @PersistenceContext This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pka...@us...> - 2009-07-23 21:19:23
|
Revision: 358 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=358&view=rev Author: pkasprzak Date: 2009-07-23 21:19:13 +0000 (Thu, 23 Jul 2009) Log Message: ----------- * Make Remote-interfaces functional Modified Paths: -------------- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerRemote.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManager.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerRemote.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/IdentityManagerRemote.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManagerRemote.java Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerRemote.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerRemote.java 2009-07-23 19:45:28 UTC (rev 357) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerRemote.java 2009-07-23 21:19:13 UTC (rev 358) @@ -12,6 +12,6 @@ * @author pete */ @Remote -public interface DependencyManagerRemote { +public interface DependencyManagerRemote extends DependencyManager { } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManager.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManager.java 2009-07-23 19:45:28 UTC (rev 357) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManager.java 2009-07-23 21:19:13 UTC (rev 358) @@ -14,16 +14,18 @@ @Local public interface EntityManager { - public int exists(String system, String systemId); + public int exists(String system, String systemId); - public int createAccount(de.campussource.cse.core.cdm.AccountType account); + public int createAccount(de.campussource.cse.core.cdm.AccountType account); - public int createCourse(de.campussource.cse.core.cdm.CourseType course); + public int createCourse(de.campussource.cse.core.cdm.CourseType course); - public int createCategory(de.campussource.cse.core.cdm.CategoryType category); + public int createCategory(de.campussource.cse.core.cdm.CategoryType category); - public int createProxy(String type); + public int createProxy(String type); - public int test(de.campussource.cse.core.cdm.EntityType entity); + public void deleteEntity(int cseId); + public int test(de.campussource.cse.core.cdm.EntityType entity); + } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java 2009-07-23 19:45:28 UTC (rev 357) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java 2009-07-23 21:19:13 UTC (rev 358) @@ -4,9 +4,11 @@ import de.campussource.cse.core.cdm.AttributeType; import de.campussource.cse.core.cdm.CategoryType; import de.campussource.cse.core.cdm.CourseType; +import de.campussource.cse.core.cdm.Utils; import de.campussource.cse.core.pdm.Attribute; import de.campussource.cse.core.pdm.Entity; import de.campussource.cse.core.pdm.EntityType; +import java.util.logging.Logger; import javax.ejb.EJB; import javax.ejb.Stateless; import javax.persistence.PersistenceContext; @@ -22,8 +24,10 @@ private javax.persistence.EntityManager em; @EJB - IdentityManager identityManager; + private IdentityManager identityManager; + private final static Logger logger = Logger.getLogger("de.campussource.cse.core.EntityManager"); + // ---------------------------------------------------------------------------------------------------------------- protected Entity createEntity() { @@ -74,6 +78,8 @@ // ---------------------------------------------------------------------------------------------------------------- public int createCourse(CourseType course) { + logger.info("Creating course: " + Utils.dumpEntity(course, true)); + Entity entity = createEntity(); entity.setType(EntityType.COURSE.toString()); @@ -121,4 +127,14 @@ Entity entity = createProxy(); return persistEntity(entity); } + + // ---------------------------------------------------------------------------------------------------------------- + public void deleteEntity(int cseId) { + Entity entity = em.find(Entity.class, cseId); + if (entity == null) { + logger.info("Entity to be deleted not found: [" + cseId + "]"); + return; + } + em.remove(entity); + } } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerRemote.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerRemote.java 2009-07-23 19:45:28 UTC (rev 357) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerRemote.java 2009-07-23 21:19:13 UTC (rev 358) @@ -12,6 +12,6 @@ * @author pete */ @Remote -public interface EntityManagerRemote { +public interface EntityManagerRemote extends EntityManager { } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/IdentityManagerRemote.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/IdentityManagerRemote.java 2009-07-23 19:45:28 UTC (rev 357) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/IdentityManagerRemote.java 2009-07-23 21:19:13 UTC (rev 358) @@ -12,6 +12,6 @@ * @author pete */ @Remote -public interface IdentityManagerRemote { +public interface IdentityManagerRemote extends IdentityManager { } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManagerRemote.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManagerRemote.java 2009-07-23 19:45:28 UTC (rev 357) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManagerRemote.java 2009-07-23 21:19:13 UTC (rev 358) @@ -12,6 +12,6 @@ * @author pete */ @Remote -public interface RelationManagerRemote { +public interface RelationManagerRemote extends RelationManager { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pka...@us...> - 2009-07-24 11:53:51
|
Revision: 363 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=363&view=rev Author: pkasprzak Date: 2009-07-24 11:53:42 +0000 (Fri, 24 Jul 2009) Log Message: ----------- * Added EntityManager.updateAttributes() for attribute checks on entities (+ some tests) * Fixed Attribute -> Entity cascades Modified Paths: -------------- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManager.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerWS.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/Attribute.java Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManager.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManager.java 2009-07-23 21:27:47 UTC (rev 362) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManager.java 2009-07-24 11:53:42 UTC (rev 363) @@ -5,6 +5,7 @@ package de.campussource.cse.core; +import de.campussource.cse.core.pdm.Entity; import javax.ejb.Local; /** @@ -14,18 +15,19 @@ @Local public interface EntityManager { - public int exists(String system, String systemId); + public int exists(String system, String systemId); - public int createAccount(de.campussource.cse.core.cdm.AccountType account); + public int createAccount(de.campussource.cse.core.cdm.AccountType account); - public int createCourse(de.campussource.cse.core.cdm.CourseType course); + public int createCourse(de.campussource.cse.core.cdm.CourseType course); - public int createCategory(de.campussource.cse.core.cdm.CategoryType category); + public int createCategory(de.campussource.cse.core.cdm.CategoryType category); - public int createProxy(String type); + public int createProxy(String type); - public void deleteEntity(int cseId); + public boolean updateAttributes(de.campussource.cse.core.cdm.EntityType entity); - public int test(de.campussource.cse.core.cdm.EntityType entity); + public void deleteEntity(int cseId); + public Entity getEntity(int cseId); } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java 2009-07-23 21:27:47 UTC (rev 362) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java 2009-07-24 11:53:42 UTC (rev 363) @@ -8,6 +8,8 @@ import de.campussource.cse.core.pdm.Attribute; import de.campussource.cse.core.pdm.Entity; import de.campussource.cse.core.pdm.EntityType; +import java.util.HashMap; +import java.util.LinkedList; import java.util.logging.Logger; import javax.ejb.EJB; import javax.ejb.Stateless; @@ -137,4 +139,64 @@ } em.remove(entity); } + + // ---------------------------------------------------------------------------------------------------------------- + public boolean updateAttributes(de.campussource.cse.core.cdm.EntityType xmlEntity) { + + boolean attributesChanged = false; + + /* Build map of attributes from xml for fast access */ + HashMap<String, AttributeType> xmlAttributesMap = new HashMap<String, AttributeType>(); + for (AttributeType xmlAttribute : xmlEntity.getAttribute()) { + xmlAttributesMap.put(xmlAttribute.getName(), xmlAttribute); + } + + Entity entity = em.find(Entity.class, xmlEntity.getBusId()); + + /* Check for changes (value changed, attribute deleted) */ + LinkedList<Attribute> newAttributes = new LinkedList<Attribute>(); + HashMap<String, Attribute> attributesMap = new HashMap<String, Attribute>(); + for (Attribute attribute : entity.getAttributes()) { + /* Build hash for later */ + attributesMap.put(attribute.getName(), attribute); + + if (!xmlAttributesMap.containsKey(attribute.getName())) { + /* Attribute has been deleted => delete in persistence + set update = true */ + em.remove(attribute); + attributesChanged = true; + continue; + } + AttributeType xmlAttribute = xmlAttributesMap.get(attribute.getName()); + newAttributes.add(attribute); + if (!attribute.getValue().equals(xmlAttribute.getValue())) { + /* Attribute value changed */ + attribute.setValue(xmlAttribute.getValue()); + attributesChanged = true; + } + } + + /* Now check, if there are new attributes on the xml side */ + for (AttributeType xmlAttribute : xmlEntity.getAttribute()) { + if (!attributesMap.containsKey(xmlAttribute.getName())) { + /* New attribute */ + Attribute attribute = new Attribute(); + attribute.setName(xmlAttribute.getName()); + attribute.setValue(xmlAttribute.getValue()); + attribute.setEntity(entity); + newAttributes.add(attribute); + attributesChanged = true; + } + } + + /* Set new attribute-list for entity */ + entity.setAttributes(newAttributes); + + return attributesChanged; + } + + // ---------------------------------------------------------------------------------------------------------------- + public Entity getEntity(int cseId) { + Entity entity = em.find(Entity.class, cseId); + return entity; + } } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerWS.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerWS.java 2009-07-23 21:27:47 UTC (rev 362) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerWS.java 2009-07-24 11:53:42 UTC (rev 363) @@ -47,9 +47,4 @@ return ejbRef.createProxy(type); } - @WebMethod(operationName = "test") - public int test( @WebParam(name = "entity") EntityType entity) { - return ejbRef.test(entity); - } - } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/Attribute.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/Attribute.java 2009-07-23 21:27:47 UTC (rev 362) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/Attribute.java 2009-07-24 11:53:42 UTC (rev 363) @@ -1,7 +1,6 @@ package de.campussource.cse.core.pdm; import java.io.Serializable; -import javax.persistence.CascadeType; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; @@ -29,7 +28,7 @@ private String value; /* Parent entity */ - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) + @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "entityId") private Entity entity; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pka...@us...> - 2009-07-24 13:58:30
|
Revision: 367 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=367&view=rev Author: pkasprzak Date: 2009-07-24 13:58:14 +0000 (Fri, 24 Jul 2009) Log Message: ----------- * EntityManager: expose updateAttributes() as WS * RelationManager: new methods for relation management Modified Paths: -------------- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerWS.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManager.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManagerImpl.java Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java 2009-07-24 11:58:32 UTC (rev 366) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java 2009-07-24 13:58:14 UTC (rev 367) @@ -119,11 +119,6 @@ } // ---------------------------------------------------------------------------------------------------------------- - public int test(de.campussource.cse.core.cdm.EntityType entity) { - return 1; - } - - // ---------------------------------------------------------------------------------------------------------------- public int createProxy(String type) { Entity entity = createProxy(); @@ -152,6 +147,7 @@ } Entity entity = em.find(Entity.class, xmlEntity.getBusId()); + entity.setProxy(false); /* Check for changes (value changed, attribute deleted) */ LinkedList<Attribute> newAttributes = new LinkedList<Attribute>(); Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerWS.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerWS.java 2009-07-24 11:58:32 UTC (rev 366) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerWS.java 2009-07-24 13:58:14 UTC (rev 367) @@ -22,29 +22,33 @@ private EntityManager ejbRef; @WebMethod(operationName = "exists") - public int exists( @WebParam(name = "system") String system, - @WebParam(name = "systemId") String systemId) { + public int exists( @WebParam(name = "system") String system, + @WebParam(name = "systemId") String systemId) { return ejbRef.exists(system, systemId); } @WebMethod(operationName = "persistAccount") - public int persistAccount( @WebParam(name = "account") AccountType account) { + public int persistAccount( @WebParam(name = "account") AccountType account) { return ejbRef.createAccount(account); } @WebMethod(operationName = "persistCourse") - public int persistCourse( @WebParam(name = "course") CourseType course) { + public int persistCourse( @WebParam(name = "course") CourseType course) { return ejbRef.createCourse(course); } @WebMethod(operationName = "persistCategory") - public int persistCategory( @WebParam(name = "category") CategoryType category) { + public int persistCategory( @WebParam(name = "category") CategoryType category) { return ejbRef.createCategory(category); } @WebMethod(operationName = "persistProxy") - public int persistProxy( @WebParam(name = "type") String type) { + public int persistProxy( @WebParam(name = "type") String type) { return ejbRef.createProxy(type); } + @WebMethod(operationName = "updateAttributes") + public boolean updateAttributes(@WebParam(name = "entity") EntityType entity) { + return ejbRef.updateAttributes(entity); + } } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManager.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManager.java 2009-07-24 11:58:32 UTC (rev 366) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManager.java 2009-07-24 13:58:14 UTC (rev 367) @@ -5,6 +5,9 @@ package de.campussource.cse.core; +import de.campussource.cse.core.pdm.Relation; +import de.campussource.cse.core.pdm.RelationType; +import java.util.List; import javax.ejb.Local; /** @@ -14,9 +17,21 @@ @Local public interface RelationManager { - public void createRelationsFromAccount(int cseId, de.campussource.cse.core.cdm.AccountType account, String system); + public List<Relation> getByParentId(int parentId); - public void createRelationsFromCourse(int cseId, de.campussource.cse.core.cdm.CourseType course, String system); + public List<Relation> getByParentIdAndType(int parentId, RelationType type); - public void createRelationsFromCategory(int cseId, de.campussource.cse.core.cdm.CategoryType category, String system); + public List<Relation> getByChildId(int childId); + + public List<Relation> getByChildIdAndType(int childId, RelationType type); + + public void deleteByChildId(int childId); + + public void deleteByParentId(int parentId); + + public void createRelationsFromAccount(int cseId, de.campussource.cse.core.cdm.AccountType account, String system); + + public void createRelationsFromCourse(int cseId, de.campussource.cse.core.cdm.CourseType course, String system); + + public void createRelationsFromCategory(int cseId, de.campussource.cse.core.cdm.CategoryType category, String system); } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManagerImpl.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManagerImpl.java 2009-07-24 11:58:32 UTC (rev 366) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/RelationManagerImpl.java 2009-07-24 13:58:14 UTC (rev 367) @@ -7,6 +7,7 @@ import de.campussource.cse.core.pdm.EntityType; import de.campussource.cse.core.pdm.Relation; import de.campussource.cse.core.pdm.RelationType; +import java.util.List; import java.util.logging.Logger; import javax.ejb.EJB; import javax.ejb.Stateless; @@ -96,4 +97,53 @@ } } + + // ---------------------------------------------------------------------------------------------------------------- + public List<Relation> getByParentId(int parentId) { + + List<Relation> relations = em.createNamedQuery(Relation.QUERY_getByParentId). setParameter("parentId", parentId). + getResultList(); + return relations; + } + + // ---------------------------------------------------------------------------------------------------------------- + public List<Relation> getByParentIdAndType(int parentId, RelationType type) { + + List<Relation> relations = em.createNamedQuery(Relation.QUERY_getByParentIdAndType).setParameter("parentId", parentId). + getResultList(); + return relations; + } + + // ---------------------------------------------------------------------------------------------------------------- + public List<Relation> getByChildId(int childId) { + + List<Relation> relations = em.createNamedQuery(Relation.QUERY_getByChildId). setParameter("childId", childId). + getResultList(); + return relations; + + } + + // ---------------------------------------------------------------------------------------------------------------- + public List<Relation> getByChildIdAndType(int childId, RelationType type) { + + List<Relation> relations = em.createNamedQuery(Relation.QUERY_getByChildIdAndType). setParameter("childId", childId). + getResultList(); + return relations; + + } + + // ---------------------------------------------------------------------------------------------------------------- + public void deleteByChildId(int childId) { + + em.createNamedQuery(Relation.QUERY_deleteByChildId). setParameter("childId", childId). + executeUpdate(); + } + + // ---------------------------------------------------------------------------------------------------------------- + public void deleteByParentId(int parentId) { + + em.createNamedQuery(Relation.QUERY_deleteByParentId). setParameter("parentId", parentId). + executeUpdate(); + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pka...@us...> - 2009-07-27 22:09:24
|
Revision: 380 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=380&view=rev Author: pkasprzak Date: 2009-07-27 22:09:18 +0000 (Mon, 27 Jul 2009) Log Message: ----------- * Stuff :) Modified Paths: -------------- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManager.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerImpl.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/Entity.java Added Paths: ----------- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/SystemManager.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/SystemManagerImpl.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/SystemManagerRemote.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/Dependency.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/DependencyStatus.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/WaitingProcess.java Removed Paths: ------------- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/Dependency.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyStatus.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyType.java Deleted: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/Dependency.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/Dependency.java 2009-07-27 22:07:54 UTC (rev 379) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/Dependency.java 2009-07-27 22:09:18 UTC (rev 380) @@ -1,93 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package de.campussource.cse.core; - -import java.io.Serializable; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -/** - * - * - * @author pete - */ -@Entity -public class Dependency implements Serializable { - - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - /* ObjectId (= BPEL ProcessId) */ - private Long objectId; - - /* Dependency-Type */ - private DependencyType type; - - /* Dependency-Status */ - private DependencyStatus status; - - @Override - public int hashCode() { - int hash = 0; - hash += (id != null ? id.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(Object object) { - // TODO: Warning - this method won't work in the case the id fields are not set - if (!(object instanceof Dependency)) { - return false; - } - Dependency other = (Dependency) object; - if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { - return false; - } - return true; - } - - @Override - public String toString() { - return "de.campussource.cse.core.Dependency[id=" + id + "]"; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getObjectId() { - return objectId; - } - - public void setObjectId(Long objectId) { - this.objectId = objectId; - } - - public DependencyStatus getStatus() { - return status; - } - - public void setStatus(DependencyStatus status) { - this.status = status; - } - - public DependencyType getType() { - return type; - } - - public void setType(DependencyType type) { - this.type = type; - } -} Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManager.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManager.java 2009-07-27 22:07:54 UTC (rev 379) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManager.java 2009-07-27 22:09:18 UTC (rev 380) @@ -14,5 +14,7 @@ @Local public interface DependencyManager { - public void checkDependencies(int objectId, DependencyType dependencyType); + public void waitForDependencies(int entityId); + + public void satisfyDependencies(int entityId, String system); } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerImpl.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerImpl.java 2009-07-27 22:07:54 UTC (rev 379) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerImpl.java 2009-07-27 22:09:18 UTC (rev 380) @@ -1,13 +1,20 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - package de.campussource.cse.core; +import de.campussource.cse.core.pdm.Dependency; +import de.campussource.cse.core.pdm.DependencyStatus; +import de.campussource.cse.core.pdm.Entity; +import de.campussource.cse.core.pdm.EntityType; +import de.campussource.cse.core.pdm.Relation; +import de.campussource.cse.core.pdm.RelationType; +import de.campussource.cse.core.pdm.WaitingProcess; +import java.util.HashSet; +import java.util.List; +import java.util.logging.Logger; +import javax.ejb.EJB; import javax.ejb.Stateless; -import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; +import javax.xml.ws.WebServiceRef; +import org.netbeans.j2ee.wsdl.common.dependencymanagernotification.DependencyManagerNotificationService; /** * @@ -15,17 +22,177 @@ */ @Stateless(mappedName = "cse/DependencyManager") public class DependencyManagerImpl implements DependencyManagerRemote, DependencyManager { + @WebServiceRef(wsdlLocation = "META-INF/wsdl/client/DependencyManagerNotification/DependencyManagerNotification.wsdl") + private DependencyManagerNotificationService service; @PersistenceContext - private EntityManager em; + private javax.persistence.EntityManager em; - public void checkDependencies(int objectId, DependencyType dependencyType) { - throw new UnsupportedOperationException("Not supported yet."); + @EJB + private RelationManager relationManager; + + @EJB + private EntityManager entityManager; + + @EJB + private IdentityManager identityManager; + + @EJB + private SystemManager systemManager; + + private final static Logger logger = Logger.getLogger("de.campussource.cse.core.DependencyManager"); + + // ---------------------------------------------------------------------------------------------------------------- + protected boolean updateDependencies(WaitingProcess process) { + + boolean satisfied = true; + process = em.merge(process); + for (Dependency dependency : process.getDependencies()) { + if (dependency.getStatus() == DependencyStatus.UNSATISFIED) { + if (identityManager.getSystemIdById(process.getSystem(), dependency.getEntityId()) != null) { + /* Entity has a valid mapping => dependency satisfied */ + dependency.setStatus(DependencyStatus.SATISFIED); + } else { + satisfied = false; + } + } + } + return satisfied; } - public void persist(Object object) { - em.persist(object); + // ---------------------------------------------------------------------------------------------------------------- + protected void createDependency(WaitingProcess process, int entityId) { + + /* Check, if dependency does not already exist */ + for (Dependency dependency : process.getDependencies()) { + if (dependency.getEntityId() == entityId) { + return; + } + } + + /* Create new dependency */ + Dependency dependency = new Dependency(); + dependency.setProcess(process); + dependency.setEntityId(entityId); + dependency.setStatus(DependencyStatus.UNSATISFIED); + process.getDependencies().add(dependency); } - - + + // ---------------------------------------------------------------------------------------------------------------- + protected WaitingProcess getWaitingProcess(int entityId, String system) { + + WaitingProcess process = (WaitingProcess) em.createNamedQuery(WaitingProcess.QUERY_getByEntityIdAndSystem). setParameter("system", system). + setParameter("entityId", entityId). + getSingleResult(); + if (process == null) { + /* No existing process found => create a new one */ + process = new WaitingProcess(); + process.setEntityId(entityId); + process.setSystem(system); + em.persist(process); + } + + return process; + } + + // ---------------------------------------------------------------------------------------------------------------- + public void waitForDependencies(int cseId) { + + Entity entity = em.find(Entity.class, cseId); + + for (String system : systemManager.getOutboundSystems()) { + + /* Create entity type dependent dependencies */ + + WaitingProcess process = getWaitingProcess(cseId, system); + + if (entity.getType().equals(EntityType.ACCOUNT.toString())) { + /* No dependencies for account objects */ + } + + if (entity.getType().equals(EntityType.COURSE.toString())) { + /* Create dependencies based on category -> course relations (course is child) */ + List<Relation> relations = relationManager.getByChildIdAndType(cseId, RelationType.CATEGORY_TO_COURSE); + for (Relation relation : relations) { + createDependency(process, relation.getParentId()); + } + } + + if (entity.getType().equals(EntityType.CATEGORY.toString())) { + /* Create dependencies based von category -> course relations (category is parent) */ + List<Relation> relations = relationManager.getByParentIdAndType(cseId, RelationType.CATEGORY_TO_COURSE); + for (Relation relation : relations) { + WaitingProcess childProcess = getWaitingProcess(relation.getChildId(), system); + createDependency(childProcess, cseId); + } + + /* Create dependencies based von category -> catgeory relations (category is parent) */ + relations = relationManager.getByParentIdAndType(cseId, RelationType.CATEGORY_TO_COURSE); + for (Relation relation : relations) { + WaitingProcess childProcess = getWaitingProcess(relation.getChildId(), system); + createDependency(childProcess, cseId); + } + } + + /* At this point all dependencies for the current entity + system have been generated => so update them */ + if (updateDependencies(process)) { + wakeUpWaitingProcess(process); + } + } + } + + // ---------------------------------------------------------------------------------------------------------------- + protected List<Dependency> getByEntityIdAndSystem(int entityId, String system) { + + List<Dependency> dependencies = em.createNamedQuery(Dependency.QUERY_getByEntityIdAndSystem). setParameter("system", system). + setParameter("entityId", entityId). + getResultList(); + + return dependencies; + } + + // ---------------------------------------------------------------------------------------------------------------- + protected void wakeUpWaitingProcess(WaitingProcess process) { + + /* Call process */ + try { + org.netbeans.j2ee.wsdl.common.dependencymanagernotification.DependencyManagerNotificationPortType port = service.getDependencyManagerNotificationPort(); + + int entityId = process.getEntityId(); + String system = process.getSystem(); + + port.notify(entityId, system); + + } catch (Exception ex) { + logger.info("Exception while trying to notify process: " + ex.getMessage()); + } + + /* Remove dependencies */ + process = em.merge(process); + em.remove(process); + } + + // ---------------------------------------------------------------------------------------------------------------- + /** + * Satisfy all dependencies waiting for the given entity. + * + * @param entityId + */ + public void satisfyDependencies(int entityId, String system) { + + HashSet<WaitingProcess> processesToTest = new HashSet<WaitingProcess>(); + + /* Tag appropriate dependencies as satisfied */ + for (Dependency dependency : getByEntityIdAndSystem(entityId, system)) { + processesToTest.add(em.merge(dependency.getProcess())); + dependency.setStatus(DependencyStatus.SATISFIED); + } + + /* Wake-up waiting processes with all dependencies satisfied */ + for (WaitingProcess process : processesToTest) { + if (updateDependencies(process)) { + wakeUpWaitingProcess(process); + } + } + } } Deleted: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyStatus.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyStatus.java 2009-07-27 22:07:54 UTC (rev 379) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyStatus.java 2009-07-27 22:09:18 UTC (rev 380) @@ -1,9 +0,0 @@ -package de.campussource.cse.core; - -/** - * - * @author pete - */ -public enum DependencyStatus { - SATISFIED, UNSATISFIED -} Deleted: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyType.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyType.java 2009-07-27 22:07:54 UTC (rev 379) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyType.java 2009-07-27 22:09:18 UTC (rev 380) @@ -1,9 +0,0 @@ -package de.campussource.cse.core; - -/** - * - * @author pete - */ -public enum DependencyType { - NONE, COURSE, CATEGORY -} Added: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/SystemManager.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/SystemManager.java (rev 0) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/SystemManager.java 2009-07-27 22:09:18 UTC (rev 380) @@ -0,0 +1,19 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package de.campussource.cse.core; + +import java.util.List; +import javax.ejb.Local; + +/** + * + * @author pete + */ +@Local +public interface SystemManager { + + public List<String> getOutboundSystems(); +} Added: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/SystemManagerImpl.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/SystemManagerImpl.java (rev 0) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/SystemManagerImpl.java 2009-07-27 22:09:18 UTC (rev 380) @@ -0,0 +1,28 @@ +package de.campussource.cse.core; + +import java.util.LinkedList; +import java.util.List; +import javax.ejb.Stateless; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +/** + * + * @author pete + */ + +@Stateless +public class SystemManagerImpl implements SystemManagerRemote, SystemManager { + + @PersistenceContext + private EntityManager em; + + public List<String> getOutboundSystems() { + + List<String> systems = new LinkedList<String>(); + systems.add("Ilias"); + + return systems; + } + +} Added: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/SystemManagerRemote.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/SystemManagerRemote.java (rev 0) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/SystemManagerRemote.java 2009-07-27 22:09:18 UTC (rev 380) @@ -0,0 +1,12 @@ +package de.campussource.cse.core; + +import javax.ejb.Remote; + +/** + * + * @author pete + */ +@Remote +public interface SystemManagerRemote extends SystemManager { + +} Added: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/Dependency.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/Dependency.java (rev 0) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/Dependency.java 2009-07-27 22:09:18 UTC (rev 380) @@ -0,0 +1,103 @@ +package de.campussource.cse.core.pdm; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; + +/** + * + * @author pete + */ + +@NamedQueries({ + + @NamedQuery( name = "Dependency.getByEntityIdAndSystem", + query = "SELECT d FROM Dependency WHERE d.process.system = :system AND d.entityId = :entityId") +}) + +@Entity +public class Dependency implements Serializable { + + public static final String QUERY_getByEntityIdAndSystem = "Dependency.getByEntityIdAndSystem"; + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + /* Process associated with (= waiting on) this dependency */ + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name = "processId") + private WaitingProcess process; + + /* Entity this dependency refers to */ + private int entityId; + + /* Current status of this dependency */ + private DependencyStatus status; + + @Override + public int hashCode() { + int hash = 0; + hash += (id != null ? id.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Dependency)) { + return false; + } + Dependency other = (Dependency) object; + if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "de.campussource.cse.core.pdm.Dependency[id=" + id + "]"; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public WaitingProcess getProcess() { + return process; + } + + public void setProcess(WaitingProcess process) { + this.process = process; + } + + public DependencyStatus getStatus() { + return status; + } + + public void setStatus(DependencyStatus status) { + this.status = status; + } + + public int getEntityId() { + return entityId; + } + + public void setEntityId(int entityId) { + this.entityId = entityId; + } +} Added: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/DependencyStatus.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/DependencyStatus.java (rev 0) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/DependencyStatus.java 2009-07-27 22:09:18 UTC (rev 380) @@ -0,0 +1,9 @@ +package de.campussource.cse.core.pdm; + +/** + * + * @author pete + */ +public enum DependencyStatus { + SATISFIED, UNSATISFIED +} Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/Entity.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/Entity.java 2009-07-27 22:07:54 UTC (rev 379) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/Entity.java 2009-07-27 22:09:18 UTC (rev 380) @@ -33,7 +33,7 @@ private boolean proxy; /* List of attributes of this object */ - @OneToMany(mappedBy="entity", cascade = CascadeType.ALL, fetch = FetchType.EAGER) + @OneToMany(mappedBy = "entityId", cascade = CascadeType.ALL, fetch = FetchType.EAGER) private Collection<Attribute> attributes = new ArrayList<Attribute>(); @Override Added: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/WaitingProcess.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/WaitingProcess.java (rev 0) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/pdm/WaitingProcess.java 2009-07-27 22:09:18 UTC (rev 380) @@ -0,0 +1,107 @@ +package de.campussource.cse.core.pdm; + +import java.io.Serializable; +import java.util.Collection; +import java.util.LinkedList; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; + +/** + * + * @author pete + */ + +@NamedQueries({ + + @NamedQuery( name = "WaitingProcess.getByEntityIdAndSystem", + query = "SELECT p FROM WaitingProcess p WHERE p.system = :system AND p.entityId = :entityId") +}) + +@Entity +public class WaitingProcess implements Serializable { + + public final static String QUERY_getByEntityIdAndSystem = "WaitingProcess.getByEntityIdAndSystem"; + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + /* Concrete dependencies associated with represented process instance */ + @OneToMany(mappedBy = "processId", cascade = CascadeType.ALL, fetch = FetchType.EAGER) + private Collection<Dependency> dependencies = new LinkedList<Dependency>(); + + /** + * Id of the associated process (will be used as correlation id for process-wakeup to identify + * the process instance) + */ + private int entityId; + + /* The system this process + associated dependencies relate to */ + private String system; + + @Override + public int hashCode() { + int hash = 0; + hash += (id != null ? id.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof WaitingProcess)) { + return false; + } + WaitingProcess other = (WaitingProcess) object; + if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "de.campussource.cse.core.pdm.WaitingProcess[id=" + id + "]"; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Collection<Dependency> getDependencies() { + return dependencies; + } + + public void setDependencies(Collection<Dependency> dependencies) { + this.dependencies = dependencies; + } + + public int getEntityId() { + return entityId; + } + + public void setEntityId(int entityId) { + this.entityId = entityId; + } + + public String getSystem() { + return system; + } + + public void setSystem(String system) { + this.system = system; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pka...@us...> - 2009-07-30 18:07:56
|
Revision: 403 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=403&view=rev Author: pkasprzak Date: 2009-07-30 18:07:36 +0000 (Thu, 30 Jul 2009) Log Message: ----------- * LoggingManager + WS-Interface Added Paths: ----------- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManager.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManagerImpl.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManagerRemote.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManagerWS.java Added: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManager.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManager.java (rev 0) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManager.java 2009-07-30 18:07:36 UTC (rev 403) @@ -0,0 +1,19 @@ +package de.campussource.cse.core; + +import javax.ejb.Local; + +/** + * + * @author pete + */ +@Local +public interface LoggingManager { + + public void debug(String process, String message); + + public void info(String process, String message); + + public void warn(String process, String message); + + public void error(String process, String message); +} Added: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManagerImpl.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManagerImpl.java (rev 0) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManagerImpl.java 2009-07-30 18:07:36 UTC (rev 403) @@ -0,0 +1,41 @@ +package de.campussource.cse.core; + +import java.util.logging.Logger; +import javax.ejb.Stateless; + +/** + * + * @author pete + */ +@Stateless +public class LoggingManagerImpl implements LoggingManagerRemote, LoggingManager { + + private final static Logger logger = Logger.getLogger("de.campussource.cse.core.LoggingManager"); + + // ---------------------------------------------------------------------------------------------------------------- + protected String constructLogMessage(String process, String message) { + + String logMessage = "*** " + process + ": " + message; + return message; + } + + // ---------------------------------------------------------------------------------------------------------------- + public void debug(String process, String message) { + logger.fine(constructLogMessage(process, message)); + } + + // ---------------------------------------------------------------------------------------------------------------- + public void info(String process, String message) { + logger.info(constructLogMessage(process, message)); + } + + // ---------------------------------------------------------------------------------------------------------------- + public void warn(String process, String message) { + logger.warning(constructLogMessage(process, message)); + } + + // ---------------------------------------------------------------------------------------------------------------- + public void error(String process, String message) { + logger.severe(constructLogMessage(process, message)); + } +} Added: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManagerRemote.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManagerRemote.java (rev 0) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManagerRemote.java 2009-07-30 18:07:36 UTC (rev 403) @@ -0,0 +1,17 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package de.campussource.cse.core; + +import javax.ejb.Remote; + +/** + * + * @author pete + */ +@Remote +public interface LoggingManagerRemote extends LoggingManager { + +} Added: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManagerWS.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManagerWS.java (rev 0) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/LoggingManagerWS.java 2009-07-30 18:07:36 UTC (rev 403) @@ -0,0 +1,48 @@ +package de.campussource.cse.core; + +import javax.ejb.EJB; +import javax.jws.Oneway; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.ejb.Stateless; + +/** + * + * @author pete + */ +@WebService(name = "LoggingManager", targetNamespace="http://cse.campussource.de/ejb/LoggingManager") +@Stateless() +public class LoggingManagerWS { + + @EJB + private LoggingManager ejbRef; + + @WebMethod(operationName = "debug") + @Oneway + public void debug( @WebParam(name = "process") String process, + @WebParam(name = "message") String message) { + ejbRef.debug(process, message); + } + + @WebMethod(operationName = "info") + @Oneway + public void info( @WebParam(name = "process") String process, + @WebParam(name = "message") String message) { + ejbRef.info(process, message); + } + + @WebMethod(operationName = "warn") + @Oneway + public void warn( @WebParam(name = "process") String process, + @WebParam(name = "message") String message) { + ejbRef.warn(process, message); + } + + @WebMethod(operationName = "error") + @Oneway + public void error( @WebParam(name = "process") String process, + @WebParam(name = "message") String message) { + ejbRef.error(process, message); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pka...@us...> - 2009-07-31 21:40:49
|
Revision: 412 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=412&view=rev Author: pkasprzak Date: 2009-07-31 21:40:29 +0000 (Fri, 31 Jul 2009) Log Message: ----------- * Added get*Context() + WS-Interface Modified Paths: -------------- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManager.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerWS.java Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManager.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManager.java 2009-07-31 21:40:08 UTC (rev 411) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManager.java 2009-07-31 21:40:29 UTC (rev 412) @@ -15,19 +15,25 @@ @Local public interface EntityManager { - public int exists(String system, String systemId); + public int exists(String system, String systemId); - public int createAccount(de.campussource.cse.core.cdm.AccountType account); + public int createAccount(de.campussource.cse.core.cdm.AccountType account); - public int createCourse(de.campussource.cse.core.cdm.CourseType course); + public int createCourse(de.campussource.cse.core.cdm.CourseType course); - public int createCategory(de.campussource.cse.core.cdm.CategoryType category); + public int createCategory(de.campussource.cse.core.cdm.CategoryType category); - public int createProxy(String type); + public de.campussource.cse.core.cdm.AccountType getAccountContext(int entityId, String system); - public boolean updateAttributes(de.campussource.cse.core.cdm.EntityType entity); + public de.campussource.cse.core.cdm.CourseType getCourseContext(int entityId, String system); - public void deleteEntity(int cseId); + public de.campussource.cse.core.cdm.CategoryType getCategoryContext(int entityId, String system); - public Entity getEntity(int cseId); + public int createProxy(String type); + + public boolean updateAttributes(de.campussource.cse.core.cdm.EntityType entity); + + public void deleteEntity(int entityId); + + public Entity getEntity(int entityId); } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java 2009-07-31 21:40:08 UTC (rev 411) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerImpl.java 2009-07-31 21:40:29 UTC (rev 412) @@ -8,6 +8,8 @@ import de.campussource.cse.core.pdm.Attribute; import de.campussource.cse.core.pdm.Entity; import de.campussource.cse.core.pdm.EntityType; +import de.campussource.cse.core.pdm.Relation; +import de.campussource.cse.core.pdm.RelationType; import java.util.HashMap; import java.util.LinkedList; import java.util.logging.Logger; @@ -28,6 +30,9 @@ @EJB private IdentityManager identityManager; + @EJB + private RelationManager relationManager; + private final static Logger logger = Logger.getLogger("de.campussource.cse.core.EntityManager"); // ---------------------------------------------------------------------------------------------------------------- @@ -50,15 +55,33 @@ protected void convertAttributes(de.campussource.cse.core.cdm.EntityType xmlEntity, Entity entity) { for (AttributeType xmlAttribute : xmlEntity.getAttribute()) { + Attribute attribute = new Attribute(); + attribute.setEntity(entity); attribute.setName(xmlAttribute.getName()); attribute.setValue(xmlAttribute.getValue()); + entity.getAttributes().add(attribute); } } // ---------------------------------------------------------------------------------------------------------------- + protected void convertAttributes(Entity entity, de.campussource.cse.core.cdm.EntityType xmlEntity) { + + for (Attribute attribute : entity.getAttributes()) { + + AttributeType xmlAttribute = new AttributeType(); + + xmlAttribute.setName(attribute.getName()); + xmlAttribute.setValue(attribute.getValue()); + xmlAttribute.setTransient(false); + + xmlEntity.getAttribute().add(xmlAttribute); + } + } + + // ---------------------------------------------------------------------------------------------------------------- protected int persistEntity(Entity entity) { em.persist(entity); @@ -197,4 +220,91 @@ Entity entity = em.find(Entity.class, cseId); return entity; } + + // ---------------------------------------------------------------------------------------------------------------- + public AccountType getAccountContext(int entityId, String system) { + + Entity entity = em.find(Entity.class, entityId); + + if (entity == null) { + logger.severe("No entity with id [" + entityId + "] found!"); + return null; + } + + if (!entity.getType().equals(EntityType.ACCOUNT.toString())) { + logger.severe("Entity [" + entityId + "] has wrong type: [" + EntityType.ACCOUNT + "] expected vs. [" + entity.getType() + "] obtained!"); + return null; + } + + AccountType xmlAccount = new AccountType(); + + convertAttributes(entity, xmlAccount); + xmlAccount.setBusId(entityId); + + return xmlAccount; + } + + // ---------------------------------------------------------------------------------------------------------------- + public CourseType getCourseContext(int entityId, String system) { + + Entity entity = em.find(Entity.class, entityId); + + if (entity == null) { + logger.severe("No entity with id [" + entityId + "] found!"); + return null; + } + + if (!entity.getType().equals(EntityType.COURSE.toString())) { + logger.severe("Entity [" + entityId + "] has wrong type: [" + EntityType.COURSE + "] expected vs. [" + entity.getType() + "] obtained!"); + return null; + } + + CourseType xmlCourse = new CourseType(); + + convertAttributes(entity, xmlCourse); + xmlCourse.setBusId(entityId); + + /* Set category -> course (course is child) relations */ + for (Relation relation : relationManager.getByChildIdAndType(entityId, RelationType.CATEGORY_TO_COURSE)) { + String systemId = identityManager.getSystemIdById(system, relation.getParentId()); + xmlCourse.getCategories().getCategory().add(systemId); + } + + return xmlCourse; + } + + // ---------------------------------------------------------------------------------------------------------------- + public CategoryType getCategoryContext(int entityId, String system) { + + Entity entity = em.find(Entity.class, entityId); + + if (entity == null) { + logger.severe("No entity with id [" + entityId + "] found!"); + return null; + } + + if (!entity.getType().equals(EntityType.CATEGORY.toString())) { + logger.severe("Entity [" + entityId + "] has wrong type: [" + EntityType.CATEGORY + "] expected vs. [" + entity.getType() + "] obtained!"); + return null; + } + + CategoryType xmlCategory = new CategoryType(); + + convertAttributes(entity, xmlCategory); + xmlCategory.setBusId(entityId); + + /* Set category -> course (category is parent) relations */ + for (Relation relation : relationManager.getByParentIdAndType(entityId, RelationType.CATEGORY_TO_COURSE)) { + String systemId = identityManager.getSystemIdById(system, relation.getChildId()); + xmlCategory.getCourses().getCourse().add(systemId); + } + + /* Set category -> category (category is parent) relations */ + for (Relation relation : relationManager.getByParentIdAndType(entityId, RelationType.CATEGORY_TO_CATEGORY)) { + String systemId = identityManager.getSystemIdById(system, relation.getChildId()); + xmlCategory.getCategories().getCategory().add(systemId); + } + + return xmlCategory; + } } Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerWS.java =================================================================== --- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerWS.java 2009-07-31 21:40:08 UTC (rev 411) +++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/EntityManagerWS.java 2009-07-31 21:40:29 UTC (rev 412) @@ -22,33 +22,51 @@ private EntityManager ejbRef; @WebMethod(operationName = "exists") - public int exists( @WebParam(name = "system") String system, - @WebParam(name = "systemId") String systemId) { + public int exists( @WebParam(name = "system") String system, + @WebParam(name = "systemId") String systemId) { return ejbRef.exists(system, systemId); } @WebMethod(operationName = "persistAccount") - public int persistAccount( @WebParam(name = "account") AccountType account) { + public int persistAccount( @WebParam(name = "account") AccountType account) { return ejbRef.createAccount(account); } @WebMethod(operationName = "persistCourse") - public int persistCourse( @WebParam(name = "course") CourseType course) { + public int persistCourse( @WebParam(name = "course") CourseType course) { return ejbRef.createCourse(course); } @WebMethod(operationName = "persistCategory") - public int persistCategory( @WebParam(name = "category") CategoryType category) { + public int persistCategory( @WebParam(name = "category") CategoryType category) { return ejbRef.createCategory(category); } @WebMethod(operationName = "persistProxy") - public int persistProxy( @WebParam(name = "type") String type) { + public int persistProxy( @WebParam(name = "type") String type) { return ejbRef.createProxy(type); } @WebMethod(operationName = "updateAttributes") - public boolean updateAttributes(@WebParam(name = "entity") EntityType entity) { + public boolean updateAttributes( @WebParam(name = "entity") EntityType entity) { return ejbRef.updateAttributes(entity); } + + @WebMethod(operationName = "getAccountContext") + public AccountType getAccountContext( @WebParam(name = "entityId") int entityId, + @WebParam(name = "system") String system) { + return ejbRef.getAccountContext(entityId, system); + } + + @WebMethod(operationName = "getCourseContext") + public CourseType getCourseContext( @WebParam(name = "entityId") int entityId, + @WebParam(name = "system") String system) { + return ejbRef.getCourseContext(entityId, system); + } + + @WebMethod(operationName = "getCategoryContext") + public CategoryType getCategoryContext( @WebParam(name = "entityId") int entityId, + @WebParam(name = "system") String system) { + return ejbRef.getCategoryContext(entityId, system); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |