1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.juddi.query;
19
20 import java.util.List;
21 import javax.persistence.EntityManager;
22 import javax.persistence.Query;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.juddi.query.util.DynamicQuery;
27
28
29
30
31
32
33
34 public class DeletePublisherAssertionByBusinessQuery extends PublisherAssertionQuery {
35
36 private static final Log log = LogFactory.getLog(DeletePublisherAssertionByBusinessQuery.class);
37
38 public static int delete(EntityManager em, List<?> businessKeys) {
39 if ((businessKeys == null) || (businessKeys.size() == 0))
40 return 0;
41
42 DynamicQuery dynamicQry = new DynamicQuery(deleteSQL);
43 appendConditions(dynamicQry, businessKeys);
44
45 log.debug(dynamicQry);
46
47 Query qry = dynamicQry.buildJPAQuery(em);
48 int result = qry.executeUpdate();
49
50 return result;
51 }
52
53
54
55
56 public static void appendConditions(DynamicQuery qry, List<?> businessKeys) {
57
58 qry.WHERE().pad().openParen().pad();
59
60 qry.appendInList(ENTITY_ALIAS + "." + FROM_KEY_NAME, businessKeys);
61 qry.pad().OR().pad();
62 qry.appendInList(ENTITY_ALIAS + "." + TO_KEY_NAME, businessKeys);
63 qry.closeParen().pad();
64
65
66 }
67
68
69 }