1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.mycore.access.mcrimpl;
20
21 import java.util.Collection;
22
23 import org.apache.logging.log4j.LogManager;
24 import org.apache.logging.log4j.Logger;
25 import org.mycore.backend.jpa.access.MCRJPARuleStore;
26 import org.mycore.common.config.MCRConfiguration2;
27
28
29
30
31
32
33
34
35
36
37 public abstract class MCRRuleStore {
38 private static final Logger LOGGER = LogManager.getLogger(MCRRuleStore.class);
39
40 protected static final String SQL_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
41
42 protected static final String RULETABLENAME = "MCRACCESSRULE";
43
44 private static MCRRuleStore implementation;
45
46 public abstract void createRule(MCRAccessRule rule);
47
48 public abstract void updateRule(MCRAccessRule rule);
49
50 public abstract void deleteRule(String ruleid);
51
52 public abstract MCRAccessRule getRule(String ruleid);
53
54 public abstract boolean existsRule(String ruleid);
55
56 public abstract Collection<String> retrieveAllIDs();
57
58 public abstract Collection<String> retrieveRuleIDs(String ruleExpression, String description);
59
60 public abstract int getNextFreeRuleID(String prefix);
61
62 public static MCRRuleStore getInstance() {
63 try {
64 if (implementation == null) {
65 implementation = MCRConfiguration2
66 .getSingleInstanceOf("MCR.Persistence.Rule.Store_Class", MCRJPARuleStore.class).get();
67 }
68 } catch (Exception e) {
69 LOGGER.error(e);
70 }
71
72 return implementation;
73 }
74 }