Loading bundles/ch.elexis.core.model/src/ch/elexis/core/model/Message.java +24 −12 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import ch.elexis.core.jpa.model.adapter.AbstractIdModelAdapter; import ch.elexis.core.model.message.MessageParty; import ch.elexis.core.model.util.internal.ModelUtil; import ch.elexis.core.services.INamedQuery; import ch.elexis.core.services.holder.CoreModelServiceHolder; public class Message extends AbstractIdDeleteModelAdapter<ch.elexis.core.jpa.entities.Message> implements Identifiable, IMessage { Loading @@ -32,18 +33,22 @@ public class Message extends AbstractIdDeleteModelAdapter<ch.elexis.core.jpa.ent @Override public IMessageParty getSender(){ Kontakt origin = getEntity().getOrigin(); return findFirstUserForContact(origin).map(e -> new MessageParty(e)).orElse(null); return findFirstUserForContact(origin).map(e -> new MessageParty(e.getId(), 0)) .orElse(null); } @SuppressWarnings("unchecked") @Override public void setSender(IMessageParty value){ IUser user = value.getUser(); if(user != null) { IContact assignedContact = user.getAssignedContact(); String identifier = value.getIdentifier(); if (value.getType() == 0) { Optional<IUser> user = CoreModelServiceHolder.get().load(identifier, IUser.class); if (user.isPresent()) { IContact assignedContact = user.get().getAssignedContact(); Kontakt entity = ((AbstractIdModelAdapter<Kontakt>) assignedContact).getEntity(); getEntityMarkDirty().setOrigin(entity); } } // TODO support for station, silently ignored by now } Loading @@ -54,7 +59,7 @@ public class Message extends AbstractIdDeleteModelAdapter<ch.elexis.core.jpa.ent */ @Override public void setSender(IUser user){ setSender(new MessageParty(user)); setSender(new MessageParty(user.getId(), 0)); } @Override Loading @@ -62,20 +67,27 @@ public class Message extends AbstractIdDeleteModelAdapter<ch.elexis.core.jpa.ent // TODO support for station Kontakt destination = getEntity().getDestination(); Optional<MessageParty> messageParty = findFirstUserForContact(destination).map(e -> new MessageParty(e)); findFirstUserForContact(destination).map(e -> new MessageParty(e.getId(), 0)); return (messageParty.isPresent()) ? Collections.singletonList(messageParty.get()) : new ArrayList<>(); } @SuppressWarnings("unchecked") @Override public void addReceiver(IMessageParty user){ public void addReceiver(IMessageParty messageParty){ List<IMessageParty> receiver = getReceiver(); receiver.add(user); receiver.add(messageParty); // TODO suppport multiple receivers Kontakt contact = ((AbstractIdModelAdapter<Kontakt>) user.getUser().getAssignedContact()).getEntity(); String identifier = messageParty.getIdentifier(); if (messageParty.getType() == 0) { Optional<IUser> user = CoreModelServiceHolder.get().load(identifier, IUser.class); if (user.isPresent()) { Kontakt contact = ((AbstractIdModelAdapter<Kontakt>) user.get().getAssignedContact()).getEntity(); getEntityMarkDirty().setDestination(contact); } } } @Override public boolean isSenderAcceptsAnswer(){ Loading bundles/ch.elexis.core.tasks/src/ch/elexis/core/tasks/internal/service/TaskServiceImpl.java +18 −19 Original line number Diff line number Diff line Loading @@ -27,14 +27,15 @@ import org.slf4j.LoggerFactory; import ch.elexis.core.model.IMessage; import ch.elexis.core.model.IUser; import ch.elexis.core.model.builder.IMessageBuilder; import ch.elexis.core.model.message.MessageCode; import ch.elexis.core.model.message.MessageParty; import ch.elexis.core.model.message.MessageParty.MessagePartyType; import ch.elexis.core.model.tasks.IIdentifiedRunnable; import ch.elexis.core.model.tasks.IIdentifiedRunnable.ReturnParameter; import ch.elexis.core.model.tasks.IIdentifiedRunnableFactory; import ch.elexis.core.model.tasks.TaskException; import ch.elexis.core.services.IContextService; import ch.elexis.core.services.IMessageService; import ch.elexis.core.services.IModelService; import ch.elexis.core.services.IQuery; import ch.elexis.core.services.IQuery.COMPARATOR; Loading @@ -56,7 +57,6 @@ public class TaskServiceImpl implements ITaskService { private Logger logger; private IModelService taskModelService; private IModelService coreModelService; private ExecutorService parallelExecutorService; private ExecutorService singletonExecutorService; Loading @@ -73,16 +73,14 @@ public class TaskServiceImpl implements ITaskService { @Reference private IContextService contextService; @Reference private IMessageService messageService; @Reference(target = "(" + IModelService.SERVICEMODELNAME + "=ch.elexis.core.tasks.model)") private void setModelService(IModelService modelService){ taskModelService = modelService; } @Reference(target = "(" + IModelService.SERVICEMODELNAME + "=ch.elexis.core.model)") private void setCoreModelService(IModelService modelService){ coreModelService = modelService; } @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC, bind = "bindRunnableWithContextFactory", unbind = "unbindRunnableWithContextFactory") private List<IIdentifiedRunnableFactory> runnableWithContextFactories; Loading Loading @@ -278,10 +276,10 @@ public class TaskServiceImpl implements ITaskService { } private void sendMessageToOwner(ITask task, IUser owner, TaskState state){ IMessage message = new IMessageBuilder(coreModelService, new MessageParty(contextService.getRootContext().getStationIdentifier()), owner) .build(); message.addMessageCode(MessageCode.Key.SenderSubId, "ch.elexis.core.tasks.taskservice"); IMessage message = messageService .prepare(new MessageParty(contextService.getRootContext().getStationIdentifier(), MessagePartyType.STATION), new MessageParty(owner.getId())); message.addMessageCode(MessageCode.Key.SenderSubId, "tasks.taskservice"); message.setSenderAcceptsAnswer(false); String resultText; Loading @@ -301,7 +299,7 @@ public class TaskServiceImpl implements ITaskService { } message.setMessageText(sb.toString()); coreModelService.save(message); messageService.send(message); } @Override Loading Loading @@ -452,7 +450,8 @@ public class TaskServiceImpl implements ITaskService { @Override public Optional<ITask> findLatestExecution(ITaskDescriptor taskDescriptor){ IQuery<ITask> query = taskModelService.getQuery(ITask.class); query.and(ModelPackage.Literals.ITASK__DESCRIPTOR_ID, COMPARATOR.EQUALS, taskDescriptor.getId()); query.and(ModelPackage.Literals.ITASK__DESCRIPTOR_ID, COMPARATOR.EQUALS, taskDescriptor.getId()); query.orderBy("lastupdate", ORDER.DESC); query.limit(1); List<ITask> result = query.execute(); Loading bundles/ch.elexis.core/model/model.ecore +8 −4 Original line number Diff line number Diff line Loading @@ -941,11 +941,15 @@ </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="IMessageParty" abstract="true" interface="true"> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> <details key="documentation" value="A user or station that either sends or receives a message. XOR user or stationId."/> <details key="documentation" value="A station, user or other type if message party."/> </eAnnotations> <eStructuralFeatures xsi:type="ecore:EReference" name="user" eType="#//IUser" changeable="false"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="stationId" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" <eStructuralFeatures xsi:type="ecore:EAttribute" name="identifier" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" changeable="false"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt" changeable="false" defaultValueLiteral="0"> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> <details key="documentation" value="The message party type: 0=user (default), 1=station; more to follow on requirement"/> </eAnnotations> </eStructuralFeatures> </eClassifiers> </ecore:EPackage> bundles/ch.elexis.core/model/model.genmodel +2 −2 Original line number Diff line number Diff line Loading @@ -630,8 +630,8 @@ </genOperations> </genClasses> <genClasses image="false" ecoreClass="model.ecore#//IMessageParty"> <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference model.ecore#//IMessageParty/user"/> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//IMessageParty/stationId"/> <genFeatures property="Readonly" createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//IMessageParty/identifier"/> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//IMessageParty/type"/> </genClasses> </genPackages> </genmodel:GenModel> bundles/ch.elexis.core/src-gen/ch/elexis/core/model/IMessageParty.java +16 −20 Original line number Diff line number Diff line Loading @@ -17,15 +17,15 @@ package ch.elexis.core.model; * <!-- end-user-doc --> * * <!-- begin-model-doc --> * A user or station that either sends or receives a message. XOR user or stationId. * A station, user or other type if message party. * <!-- end-model-doc --> * * <p> * The following features are supported: * </p> * <ul> * <li>{@link ch.elexis.core.model.IMessageParty#getUser <em>User</em>}</li> * <li>{@link ch.elexis.core.model.IMessageParty#getStationId <em>Station Id</em>}</li> * <li>{@link ch.elexis.core.model.IMessageParty#getIdentifier <em>Identifier</em>}</li> * <li>{@link ch.elexis.core.model.IMessageParty#getType <em>Type</em>}</li> * </ul> * * @see ch.elexis.core.model.ModelPackage#getIMessageParty() Loading @@ -34,33 +34,29 @@ package ch.elexis.core.model; */ public interface IMessageParty { /** * Returns the value of the '<em><b>User</b></em>' reference. * Returns the value of the '<em><b>Identifier</b></em>' attribute. * <!-- begin-user-doc --> * <p> * If the meaning of the '<em>User</em>' reference isn't clear, * there really should be more of a description here... * </p> * <!-- end-user-doc --> * @return the value of the '<em>User</em>' reference. * @see ch.elexis.core.model.ModelPackage#getIMessageParty_User() * @return the value of the '<em>Identifier</em>' attribute. * @see ch.elexis.core.model.ModelPackage#getIMessageParty_Identifier() * @model changeable="false" * @generated */ IUser getUser(); String getIdentifier(); /** * Returns the value of the '<em><b>Station Id</b></em>' attribute. * Returns the value of the '<em><b>Type</b></em>' attribute. * The default value is <code>"0"</code>. * <!-- begin-user-doc --> * <p> * If the meaning of the '<em>Station Id</em>' attribute isn't clear, * there really should be more of a description here... * </p> * <!-- end-user-doc --> * @return the value of the '<em>Station Id</em>' attribute. * @see ch.elexis.core.model.ModelPackage#getIMessageParty_StationId() * @model changeable="false" * <!-- begin-model-doc --> * The message party type: 0=user (default), 1=station; more to follow on requirement * <!-- end-model-doc --> * @return the value of the '<em>Type</em>' attribute. * @see ch.elexis.core.model.ModelPackage#getIMessageParty_Type() * @model default="0" required="true" changeable="false" * @generated */ String getStationId(); int getType(); } // IMessageParty Loading
bundles/ch.elexis.core.model/src/ch/elexis/core/model/Message.java +24 −12 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import ch.elexis.core.jpa.model.adapter.AbstractIdModelAdapter; import ch.elexis.core.model.message.MessageParty; import ch.elexis.core.model.util.internal.ModelUtil; import ch.elexis.core.services.INamedQuery; import ch.elexis.core.services.holder.CoreModelServiceHolder; public class Message extends AbstractIdDeleteModelAdapter<ch.elexis.core.jpa.entities.Message> implements Identifiable, IMessage { Loading @@ -32,18 +33,22 @@ public class Message extends AbstractIdDeleteModelAdapter<ch.elexis.core.jpa.ent @Override public IMessageParty getSender(){ Kontakt origin = getEntity().getOrigin(); return findFirstUserForContact(origin).map(e -> new MessageParty(e)).orElse(null); return findFirstUserForContact(origin).map(e -> new MessageParty(e.getId(), 0)) .orElse(null); } @SuppressWarnings("unchecked") @Override public void setSender(IMessageParty value){ IUser user = value.getUser(); if(user != null) { IContact assignedContact = user.getAssignedContact(); String identifier = value.getIdentifier(); if (value.getType() == 0) { Optional<IUser> user = CoreModelServiceHolder.get().load(identifier, IUser.class); if (user.isPresent()) { IContact assignedContact = user.get().getAssignedContact(); Kontakt entity = ((AbstractIdModelAdapter<Kontakt>) assignedContact).getEntity(); getEntityMarkDirty().setOrigin(entity); } } // TODO support for station, silently ignored by now } Loading @@ -54,7 +59,7 @@ public class Message extends AbstractIdDeleteModelAdapter<ch.elexis.core.jpa.ent */ @Override public void setSender(IUser user){ setSender(new MessageParty(user)); setSender(new MessageParty(user.getId(), 0)); } @Override Loading @@ -62,20 +67,27 @@ public class Message extends AbstractIdDeleteModelAdapter<ch.elexis.core.jpa.ent // TODO support for station Kontakt destination = getEntity().getDestination(); Optional<MessageParty> messageParty = findFirstUserForContact(destination).map(e -> new MessageParty(e)); findFirstUserForContact(destination).map(e -> new MessageParty(e.getId(), 0)); return (messageParty.isPresent()) ? Collections.singletonList(messageParty.get()) : new ArrayList<>(); } @SuppressWarnings("unchecked") @Override public void addReceiver(IMessageParty user){ public void addReceiver(IMessageParty messageParty){ List<IMessageParty> receiver = getReceiver(); receiver.add(user); receiver.add(messageParty); // TODO suppport multiple receivers Kontakt contact = ((AbstractIdModelAdapter<Kontakt>) user.getUser().getAssignedContact()).getEntity(); String identifier = messageParty.getIdentifier(); if (messageParty.getType() == 0) { Optional<IUser> user = CoreModelServiceHolder.get().load(identifier, IUser.class); if (user.isPresent()) { Kontakt contact = ((AbstractIdModelAdapter<Kontakt>) user.get().getAssignedContact()).getEntity(); getEntityMarkDirty().setDestination(contact); } } } @Override public boolean isSenderAcceptsAnswer(){ Loading
bundles/ch.elexis.core.tasks/src/ch/elexis/core/tasks/internal/service/TaskServiceImpl.java +18 −19 Original line number Diff line number Diff line Loading @@ -27,14 +27,15 @@ import org.slf4j.LoggerFactory; import ch.elexis.core.model.IMessage; import ch.elexis.core.model.IUser; import ch.elexis.core.model.builder.IMessageBuilder; import ch.elexis.core.model.message.MessageCode; import ch.elexis.core.model.message.MessageParty; import ch.elexis.core.model.message.MessageParty.MessagePartyType; import ch.elexis.core.model.tasks.IIdentifiedRunnable; import ch.elexis.core.model.tasks.IIdentifiedRunnable.ReturnParameter; import ch.elexis.core.model.tasks.IIdentifiedRunnableFactory; import ch.elexis.core.model.tasks.TaskException; import ch.elexis.core.services.IContextService; import ch.elexis.core.services.IMessageService; import ch.elexis.core.services.IModelService; import ch.elexis.core.services.IQuery; import ch.elexis.core.services.IQuery.COMPARATOR; Loading @@ -56,7 +57,6 @@ public class TaskServiceImpl implements ITaskService { private Logger logger; private IModelService taskModelService; private IModelService coreModelService; private ExecutorService parallelExecutorService; private ExecutorService singletonExecutorService; Loading @@ -73,16 +73,14 @@ public class TaskServiceImpl implements ITaskService { @Reference private IContextService contextService; @Reference private IMessageService messageService; @Reference(target = "(" + IModelService.SERVICEMODELNAME + "=ch.elexis.core.tasks.model)") private void setModelService(IModelService modelService){ taskModelService = modelService; } @Reference(target = "(" + IModelService.SERVICEMODELNAME + "=ch.elexis.core.model)") private void setCoreModelService(IModelService modelService){ coreModelService = modelService; } @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC, bind = "bindRunnableWithContextFactory", unbind = "unbindRunnableWithContextFactory") private List<IIdentifiedRunnableFactory> runnableWithContextFactories; Loading Loading @@ -278,10 +276,10 @@ public class TaskServiceImpl implements ITaskService { } private void sendMessageToOwner(ITask task, IUser owner, TaskState state){ IMessage message = new IMessageBuilder(coreModelService, new MessageParty(contextService.getRootContext().getStationIdentifier()), owner) .build(); message.addMessageCode(MessageCode.Key.SenderSubId, "ch.elexis.core.tasks.taskservice"); IMessage message = messageService .prepare(new MessageParty(contextService.getRootContext().getStationIdentifier(), MessagePartyType.STATION), new MessageParty(owner.getId())); message.addMessageCode(MessageCode.Key.SenderSubId, "tasks.taskservice"); message.setSenderAcceptsAnswer(false); String resultText; Loading @@ -301,7 +299,7 @@ public class TaskServiceImpl implements ITaskService { } message.setMessageText(sb.toString()); coreModelService.save(message); messageService.send(message); } @Override Loading Loading @@ -452,7 +450,8 @@ public class TaskServiceImpl implements ITaskService { @Override public Optional<ITask> findLatestExecution(ITaskDescriptor taskDescriptor){ IQuery<ITask> query = taskModelService.getQuery(ITask.class); query.and(ModelPackage.Literals.ITASK__DESCRIPTOR_ID, COMPARATOR.EQUALS, taskDescriptor.getId()); query.and(ModelPackage.Literals.ITASK__DESCRIPTOR_ID, COMPARATOR.EQUALS, taskDescriptor.getId()); query.orderBy("lastupdate", ORDER.DESC); query.limit(1); List<ITask> result = query.execute(); Loading
bundles/ch.elexis.core/model/model.ecore +8 −4 Original line number Diff line number Diff line Loading @@ -941,11 +941,15 @@ </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="IMessageParty" abstract="true" interface="true"> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> <details key="documentation" value="A user or station that either sends or receives a message. XOR user or stationId."/> <details key="documentation" value="A station, user or other type if message party."/> </eAnnotations> <eStructuralFeatures xsi:type="ecore:EReference" name="user" eType="#//IUser" changeable="false"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="stationId" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" <eStructuralFeatures xsi:type="ecore:EAttribute" name="identifier" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" changeable="false"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt" changeable="false" defaultValueLiteral="0"> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> <details key="documentation" value="The message party type: 0=user (default), 1=station; more to follow on requirement"/> </eAnnotations> </eStructuralFeatures> </eClassifiers> </ecore:EPackage>
bundles/ch.elexis.core/model/model.genmodel +2 −2 Original line number Diff line number Diff line Loading @@ -630,8 +630,8 @@ </genOperations> </genClasses> <genClasses image="false" ecoreClass="model.ecore#//IMessageParty"> <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference model.ecore#//IMessageParty/user"/> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//IMessageParty/stationId"/> <genFeatures property="Readonly" createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//IMessageParty/identifier"/> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//IMessageParty/type"/> </genClasses> </genPackages> </genmodel:GenModel>
bundles/ch.elexis.core/src-gen/ch/elexis/core/model/IMessageParty.java +16 −20 Original line number Diff line number Diff line Loading @@ -17,15 +17,15 @@ package ch.elexis.core.model; * <!-- end-user-doc --> * * <!-- begin-model-doc --> * A user or station that either sends or receives a message. XOR user or stationId. * A station, user or other type if message party. * <!-- end-model-doc --> * * <p> * The following features are supported: * </p> * <ul> * <li>{@link ch.elexis.core.model.IMessageParty#getUser <em>User</em>}</li> * <li>{@link ch.elexis.core.model.IMessageParty#getStationId <em>Station Id</em>}</li> * <li>{@link ch.elexis.core.model.IMessageParty#getIdentifier <em>Identifier</em>}</li> * <li>{@link ch.elexis.core.model.IMessageParty#getType <em>Type</em>}</li> * </ul> * * @see ch.elexis.core.model.ModelPackage#getIMessageParty() Loading @@ -34,33 +34,29 @@ package ch.elexis.core.model; */ public interface IMessageParty { /** * Returns the value of the '<em><b>User</b></em>' reference. * Returns the value of the '<em><b>Identifier</b></em>' attribute. * <!-- begin-user-doc --> * <p> * If the meaning of the '<em>User</em>' reference isn't clear, * there really should be more of a description here... * </p> * <!-- end-user-doc --> * @return the value of the '<em>User</em>' reference. * @see ch.elexis.core.model.ModelPackage#getIMessageParty_User() * @return the value of the '<em>Identifier</em>' attribute. * @see ch.elexis.core.model.ModelPackage#getIMessageParty_Identifier() * @model changeable="false" * @generated */ IUser getUser(); String getIdentifier(); /** * Returns the value of the '<em><b>Station Id</b></em>' attribute. * Returns the value of the '<em><b>Type</b></em>' attribute. * The default value is <code>"0"</code>. * <!-- begin-user-doc --> * <p> * If the meaning of the '<em>Station Id</em>' attribute isn't clear, * there really should be more of a description here... * </p> * <!-- end-user-doc --> * @return the value of the '<em>Station Id</em>' attribute. * @see ch.elexis.core.model.ModelPackage#getIMessageParty_StationId() * @model changeable="false" * <!-- begin-model-doc --> * The message party type: 0=user (default), 1=station; more to follow on requirement * <!-- end-model-doc --> * @return the value of the '<em>Type</em>' attribute. * @see ch.elexis.core.model.ModelPackage#getIMessageParty_Type() * @model default="0" required="true" changeable="false" * @generated */ String getStationId(); int getType(); } // IMessageParty