Requirement: Automatically activating/deactivating a Spazio Listener/Even.
Solution: Use the following custom plugin for activating/deactivating the Spazio Listener/Event.
import java.util.*;
import javax.security.auth.Subject;
import com.adeptia.indigo.event.Event;
import com.adeptia.indigo.storage.Entity;
import com.adeptia.indigo.event.EventUtils;
import com.adeptia.indigo.logging.Logger;
import com.adeptia.indigo.storage.EntityManager;
import com.adeptia.indigo.storage.EntityManagerFactory;
Map eventMap = (Map) context.get("EventContextMap");
String EventParam;
String TypeID;
String Activation;
if(eventMap != null){
EventParam = (String) eventMap.get("EventParam");
TypeID = EventParam.substring( 0, EventParam.indexOf(','));
Activation=EventParam.substring( EventParam.indexOf(',')+1);}
Logger log = service.getLogger();
String eventID = TypeID;
Subject sub = service.getSubject();
Entity entity = EventUtils.getEntity(eventID, sub);
if (entity != null) {
log.info("entity name: "+entity.getEntityName());
Event event = ((Event) entity);
event.setSubject(sub);
if (Activation.equals("Deactivate")) {
event.deactivateEvent(eventID , sub);
event.setActivateFlag(false);
EntityManager entityManager = EntityManagerFactory.getEntityManager(entity.getClass(), sub);
entityManager.update(entity);
}
else {
event.activate();
event.setActivateFlag(true);
EntityManager entityManager = EntityManagerFactory.getEntityManager(entity.getClass(), sub);
entityManager.update(entity);
}}
Note: Users may be required to modify the custom plugin script as per their requirement.
Comments
0 comments
Article is closed for comments.