Skip to content

Package: JOPAPersistenceProvider

JOPAPersistenceProvider

nameinstructionbranchcomplexitylinemethod
JOPAPersistenceProvider()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createEntityManagerFactory(String, Map)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getProviderUtil()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isLoaded(Object)
M: 14 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
isLoadedWithReference(Object, String)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isLoadedWithoutReference(Object, String)
M: 15 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
lambda$isLoaded$0(Object, EntityManagerFactoryImpl)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
lambda$isLoaded$1(EntityManagerFactoryImpl)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
lambda$isLoadedWithoutReference$2(Object, String, EntityManagerFactoryImpl)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
lambda$isLoadedWithoutReference$3(EntityManagerFactoryImpl)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2022 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.model;
16:
17: import java.util.*;
18:
19: public class JOPAPersistenceProvider implements PersistenceProvider, ProviderUtil {
20:
21: private static final Set<EntityManagerFactoryImpl> EMFS = Collections.synchronizedSet(new HashSet<>());
22:
23: @Override
24: public EntityManagerFactoryImpl createEntityManagerFactory(String emName, Map<String, String> properties) {
25: final EntityManagerFactoryImpl emf = new EntityManagerFactoryImpl(properties);
26: EMFS.add(emf);
27: return emf;
28: }
29:
30: @Override
31: public ProviderUtil getProviderUtil() {
32: return this;
33: }
34:
35: @Override
36: public LoadState isLoaded(Object entity) {
37: final Optional<EntityManagerFactoryImpl> found = EMFS.stream().filter(emf -> emf.isLoaded(entity)).findAny();
38: return found.map(entityManagerFactory -> LoadState.LOADED).orElse(LoadState.UNKNOWN);
39: }
40:
41: @Override
42: public LoadState isLoadedWithReference(Object entity, String attributeName) {
43: return isLoadedWithoutReference(entity, attributeName);
44: }
45:
46: @Override
47: public LoadState isLoadedWithoutReference(Object entity, String attributeName) {
48: final Optional<EntityManagerFactoryImpl> found = EMFS.stream()
49: .filter(emf -> emf.isLoaded(entity, attributeName))
50: .findAny();
51: return found.map(entityManagerFactory -> LoadState.LOADED).orElse(LoadState.UNKNOWN);
52: }
53: }