Revision 76db2374
Added by Andreas Müller almost 7 years ago
cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/media/MediaInfo.java | ||
---|---|---|
19 | 19 |
public abstract class MediaInfo { |
20 | 20 |
@SuppressWarnings("unused") |
21 | 21 |
private static Logger logger = Logger.getLogger(MediaInfo.class); |
22 |
|
|
22 | 23 |
private String formatName; |
23 | 24 |
private String mimeType; |
24 | 25 |
private long length; |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/operation/DeleteNonReferencedReferencesUpdater.java | ||
---|---|---|
1 |
package eu.etaxonomy.cdm.io.operation; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Set; |
|
5 |
|
|
6 |
import org.springframework.stereotype.Component; |
|
7 |
|
|
8 |
import eu.etaxonomy.cdm.api.service.DeleteResult; |
|
9 |
import eu.etaxonomy.cdm.io.common.CdmImportBase; |
|
10 |
import eu.etaxonomy.cdm.io.common.DefaultImportState; |
|
11 |
import eu.etaxonomy.cdm.io.operation.config.DeleteNonReferencedReferencesConfigurator; |
|
12 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
13 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
14 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
15 |
@Component |
|
16 |
|
|
17 |
public class DeleteNonReferencedReferencesUpdater extends CdmImportBase<DeleteNonReferencedReferencesConfigurator, DefaultImportState<DeleteNonReferencedReferencesConfigurator>> { |
|
18 |
|
|
19 |
private static final long serialVersionUID = -3514276133181062270L; |
|
20 |
|
|
21 |
@Override |
|
22 |
protected void doInvoke( |
|
23 |
DefaultImportState<DeleteNonReferencedReferencesConfigurator> state) { |
|
24 |
|
|
25 |
if (state.getConfig().isDoAuthors()){ |
|
26 |
List<TeamOrPersonBase> authors =getAgentService().list(TeamOrPersonBase.class, null, null, null, null); |
|
27 |
DeleteResult result; |
|
28 |
int deleted = 0; |
|
29 |
System.out.println("There are " + authors.size() + " authors"); |
|
30 |
for (TeamOrPersonBase author: authors){ |
|
31 |
Set<CdmBase> refObjects = getCommonService().getReferencingObjects(author); |
|
32 |
if (refObjects.isEmpty()) { |
|
33 |
result = getAgentService().delete(author); |
|
34 |
deleted++; |
|
35 |
if (!result.isOk()){ |
|
36 |
System.out.println("Author " + author.getTitleCache() + " with id " + author.getId() + " could not be deleted."); |
|
37 |
result = null; |
|
38 |
} |
|
39 |
} |
|
40 |
} |
|
41 |
System.out.println(deleted + " authors are deleted."); |
|
42 |
} |
|
43 |
if (state.getConfig().isDoReferences()){ |
|
44 |
List<Reference> references =getReferenceService().list(Reference.class, null, null, null, null); |
|
45 |
DeleteResult result; |
|
46 |
int deleted = 0; |
|
47 |
System.out.println("There are " + references.size() + " references"); |
|
48 |
for (Reference ref: references){ |
|
49 |
Set<CdmBase> refObjects = getCommonService().getReferencingObjects(ref); |
|
50 |
if (refObjects.isEmpty()) { |
|
51 |
result = getReferenceService().delete(ref); |
|
52 |
deleted++; |
|
53 |
if (!result.isOk()){ |
|
54 |
System.out.println("Reference " + ref.getTitle() + " with id " + ref.getId() + " could not be deleted."); |
|
55 |
result = null; |
|
56 |
} |
|
57 |
} |
|
58 |
} |
|
59 |
System.out.println(deleted + " references are deleted."); |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
protected boolean doCheck( |
|
65 |
DefaultImportState<DeleteNonReferencedReferencesConfigurator> state) { |
|
66 |
return true; |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
protected boolean isIgnore( |
|
71 |
DefaultImportState<DeleteNonReferencedReferencesConfigurator> state) { |
|
72 |
return false; |
|
73 |
} |
|
74 |
|
|
75 |
|
|
76 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/operation/DeleteNonReferencedreferencesUpdater.java | ||
---|---|---|
1 |
package eu.etaxonomy.cdm.io.operation; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Set; |
|
5 |
|
|
6 |
import org.springframework.stereotype.Component; |
|
7 |
|
|
8 |
import eu.etaxonomy.cdm.api.service.DeleteResult; |
|
9 |
import eu.etaxonomy.cdm.io.common.CdmImportBase; |
|
10 |
import eu.etaxonomy.cdm.io.common.DefaultImportState; |
|
11 |
import eu.etaxonomy.cdm.io.operation.config.DeleteNonReferencedReferencesConfigurator; |
|
12 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
13 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
14 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
15 |
@Component |
|
16 |
|
|
17 |
public class DeleteNonReferencedreferencesUpdater extends CdmImportBase<DeleteNonReferencedReferencesConfigurator, DefaultImportState<DeleteNonReferencedReferencesConfigurator>> { |
|
18 |
|
|
19 |
|
|
20 |
@Override |
|
21 |
protected void doInvoke( |
|
22 |
DefaultImportState<DeleteNonReferencedReferencesConfigurator> state) { |
|
23 |
|
|
24 |
if (state.getConfig().isDoAuthors()){ |
|
25 |
List<TeamOrPersonBase> authors =getAgentService().list(TeamOrPersonBase.class, null, null, null, null); |
|
26 |
DeleteResult result; |
|
27 |
int deleted = 0; |
|
28 |
System.out.println("There are " + authors.size() + " authors"); |
|
29 |
for (TeamOrPersonBase author: authors){ |
|
30 |
Set<CdmBase> refObjects = getCommonService().getReferencingObjects(author); |
|
31 |
if (refObjects.isEmpty()) { |
|
32 |
result = getAgentService().delete(author); |
|
33 |
deleted++; |
|
34 |
if (!result.isOk()){ |
|
35 |
System.out.println("Author " + author.getTitleCache() + " with id " + author.getId() + " could not be deleted."); |
|
36 |
result = null; |
|
37 |
} |
|
38 |
} |
|
39 |
} |
|
40 |
System.out.println(deleted + " authors are deleted."); |
|
41 |
} |
|
42 |
if (state.getConfig().isDoReferences()){ |
|
43 |
List<Reference> references =getReferenceService().list(Reference.class, null, null, null, null); |
|
44 |
DeleteResult result; |
|
45 |
int deleted = 0; |
|
46 |
System.out.println("There are " + references.size() + " references"); |
|
47 |
for (Reference ref: references){ |
|
48 |
Set<CdmBase> refObjects = getCommonService().getReferencingObjects(ref); |
|
49 |
if (refObjects.isEmpty()) { |
|
50 |
result = getReferenceService().delete(ref); |
|
51 |
deleted++; |
|
52 |
if (!result.isOk()){ |
|
53 |
System.out.println("Reference " + ref.getTitle() + " with id " + ref.getId() + " could not be deleted."); |
|
54 |
result = null; |
|
55 |
} |
|
56 |
} |
|
57 |
} |
|
58 |
System.out.println(deleted + " references are deleted."); |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
protected boolean doCheck( |
|
64 |
DefaultImportState<DeleteNonReferencedReferencesConfigurator> state) { |
|
65 |
// TODO Auto-generated method stub |
|
66 |
return false; |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
protected boolean isIgnore( |
|
71 |
DefaultImportState<DeleteNonReferencedReferencesConfigurator> state) { |
|
72 |
// TODO Auto-generated method stub |
|
73 |
return false; |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/operation/config/DeleteNonReferencedReferencesConfigurator.java | ||
---|---|---|
9 | 9 |
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase; |
10 | 10 |
import eu.etaxonomy.cdm.io.common.ImportStateBase; |
11 | 11 |
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer; |
12 |
import eu.etaxonomy.cdm.io.operation.DeleteNonReferencedreferencesUpdater;
|
|
12 |
import eu.etaxonomy.cdm.io.operation.DeleteNonReferencedReferencesUpdater;
|
|
13 | 13 |
import eu.etaxonomy.cdm.model.reference.Reference; |
14 | 14 |
|
15 | 15 |
public class DeleteNonReferencedReferencesConfigurator extends ImportConfiguratorBase<DefaultImportState<DeleteNonReferencedReferencesConfigurator>, Object> implements IImportConfigurator{ |
... | ... | |
69 | 69 |
@Override |
70 | 70 |
protected void makeIoClassList() { |
71 | 71 |
ioClassList = new Class[]{ |
72 |
DeleteNonReferencedreferencesUpdater.class
|
|
72 |
DeleteNonReferencedReferencesUpdater.class
|
|
73 | 73 |
}; |
74 | 74 |
} |
75 | 75 |
|
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/permission/CdmAuthority.java | ||
---|---|---|
70 | 70 |
|
71 | 71 |
private static Map<String, CdmAuthority> grantedAuthorityCache = new HashMap<>(); |
72 | 72 |
|
73 |
CdmPermissionClass permissionClass; |
|
74 |
String property; |
|
73 |
private CdmPermissionClass permissionClass;
|
|
74 |
private String property;
|
|
75 | 75 |
// Making sure that operation is always initialized, for both |
76 | 76 |
// - the string representation to have a '[]' |
77 | 77 |
// - and the object representation to never be null (with check in constructors) |
78 |
EnumSet<CRUD> operation = EnumSet.noneOf(CRUD.class); |
|
79 |
UUID targetUuid; |
|
78 |
private EnumSet<CRUD> operation = EnumSet.noneOf(CRUD.class);
|
|
79 |
private UUID targetUuid;
|
|
80 | 80 |
|
81 | 81 |
public CdmAuthority(CdmBase targetDomainObject, EnumSet<CRUD> operation){ |
82 | 82 |
|
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IdentifiableServiceBase.java | ||
---|---|---|
511 | 511 |
}else{ |
512 | 512 |
//<> titleCache |
513 | 513 |
dedupState.result += handleLastGroup(nextGroup, matchStrategy, mergeStrategy); |
514 |
nextGroup = new ArrayList<T>();
|
|
514 |
nextGroup = new ArrayList<>(); |
|
515 | 515 |
nextGroup.add(object); |
516 | 516 |
nUnEqual++; |
517 | 517 |
} |
Also available in: Unified diff
cleanup