View Javadoc
1 package org.smartcomps.twister.engine.priv.core.definition; 2 3 import org.smartcomps.twister.common.persistence.DBSessionException; 4 import org.smartcomps.twister.engine.priv.core.definition.impl.ProcessImpl; 5 import org.smartcomps.twister.engine.priv.core.definition.impl.CorrelationSetImpl; 6 import org.smartcomps.twister.engine.priv.core.definition.impl.PropertyImpl; 7 import org.smartcomps.twister.engine.priv.core.definition.impl.PropertyAliasImpl; 8 import org.smartcomps.twister.engine.priv.core.definition.impl.dao.ProcessDAO; 9 import org.smartcomps.twister.common.persistence.FinderException; 10 import org.smartcomps.twister.common.persistence.CreationException; 11 12 public class ProcessFactory { 13 14 /*** 15 * Creates a new Process persistance instance. 16 * @param name of the Process to create 17 * @return TwisterProcess initiated with the provided name 18 * @throws DBSessionException 19 * @throws DBSessionException 20 */ 21 public static TwisterProcess createProcess(String name) throws DBSessionException, CreationException { 22 try { 23 getByName(name); 24 throw new CreationException("There's already a process named " + name); 25 } catch (FinderException e) { } 26 ProcessImpl process = new ProcessImpl(); 27 process.setName(name); 28 process = (ProcessImpl) ProcessDAO.create(process); 29 return process; 30 } 31 32 public static CorrelationSet addCorrelation(TwisterProcess process, String correlationName, String correlationProps) throws DBSessionException, FinderException { 33 CorrelationSetImpl correlationSet = new CorrelationSetImpl(); 34 correlationSet.setName(correlationName); 35 correlationSet.setPropertiesString(correlationProps); 36 37 TwisterProcess persistentProcess = getByName(process.getName()); 38 ((ProcessImpl)persistentProcess).addCorrelationSet(correlationSet); 39 40 ProcessDAO.create(correlationSet); 41 // ProcessDAO.update(persistentProcess); 42 43 return correlationSet; 44 } 45 46 public static Property addProperty(TwisterProcess process, String name, 47 String type) throws DBSessionException, FinderException { 48 49 PropertyImpl property = new PropertyImpl(); 50 property.setName(name); 51 property.setType(type); 52 53 TwisterProcess persistentProcess = getByName(process.getName()); 54 ((ProcessImpl)persistentProcess).addProperty(property); 55 56 ProcessDAO.create(property); 57 58 return property; 59 } 60 61 public static Property addProperty(TwisterProcess process, String name, String type, String msgType, String part, 62 String query) throws DBSessionException, FinderException { 63 64 PropertyImpl property = new PropertyImpl(); 65 property.setName(name); 66 property.setType(type); 67 PropertyAliasImpl alias = new PropertyAliasImpl(); 68 alias.setMessageType(msgType); 69 alias.setPart(part); 70 alias.setQuery(query); 71 property.setAlias(alias); 72 73 TwisterProcess persistentProcess = getByName(process.getName()); 74 ((ProcessImpl)persistentProcess).addProperty(property); 75 76 ProcessDAO.create(property); 77 ProcessDAO.create(alias); 78 // ProcessDAO.update(persistentProcess); 79 80 return property; 81 } 82 83 /*** 84 * Finds a persistent Process from its name. 85 * @param name 86 * @return TwisterProcess 87 * @throws DBSessionException 88 * @throws DBSessionException 89 */ 90 public static TwisterProcess getByName(String name) throws DBSessionException, FinderException { 91 TwisterProcess process = ProcessDAO.findByName(name); 92 if (process == null) throw new FinderException("Could not find a process with name : " + name); 93 return process; 94 } 95 96 }

This page was automatically generated by Maven