Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DocExplore
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander BURNETT
DocExplore
Commits
5b5201fb
Commit
5b5201fb
authored
6 years ago
by
aburn
Browse files
Options
Downloads
Patches
Plain Diff
Removed MMT dependency
parent
692fde03
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/org/interreg/docexplore/management/manage/DataLinkCleaner.java
+99
-99
99 additions, 99 deletions
...nterreg/docexplore/management/manage/DataLinkCleaner.java
with
99 additions
and
99 deletions
src/org/interreg/docexplore/management/manage/DataLinkCleaner.java
+
99
−
99
View file @
5b5201fb
...
...
@@ -12,8 +12,8 @@ In this respect, the user's attention is drawn to the risks associated with load
The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms.
*/
package
org.interreg.docexplore.management.manage
;
package
org.interreg.docexplore.management.manage
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -23,7 +23,6 @@ import java.util.TreeSet;
import
org.interreg.docexplore.datalink.DataLinkException
;
import
org.interreg.docexplore.gui.ErrorHandler
;
import
org.interreg.docexplore.internationalization.Lang
;
import
org.interreg.docexplore.management.gui.MMTApp
;
import
org.interreg.docexplore.manuscript.AnnotatedObject
;
import
org.interreg.docexplore.manuscript.Book
;
import
org.interreg.docexplore.manuscript.DocExploreDataLink
;
...
...
@@ -31,99 +30,100 @@ import org.interreg.docexplore.manuscript.MetaData;
import
org.interreg.docexplore.manuscript.MetaDataKey
;
import
org.interreg.docexplore.manuscript.Page
;
import
org.interreg.docexplore.manuscript.Region
;
import
org.interreg.docexplore.util.GuiUtils.ProgressRunnable
;
public
class
DataLinkCleaner
implements
ProgressRunnable
{
MMTApp
win
;
public
DataLinkCleaner
(
MMTApp
win
)
{
this
.
win
=
win
;
}
public
void
run
()
{
try
{
DocExploreDataLink
link
=
win
.
host
.
getLink
();
if
(
link
.
getLink
()
==
null
)
throw
new
Exception
(
Lang
.
s
(
"cleanLinkNoConnection"
));
Set
<
Integer
>
referencedIds
=
getAllReferencedMetaDataIds
(
link
);
Set
<
Integer
>
allIds
=
new
TreeSet
<
Integer
>();
Collection
<
MetaDataKey
>
keys
=
link
.
getAllKeys
();
int
cnt
=
0
;
for
(
MetaDataKey
key
:
keys
)
{
allIds
.
addAll
(
link
.
getLink
().
getMetaDataIds
(
key
.
getId
(),
null
));
cnt
++;
progress
=
.
5
f
+
cnt
*.
25
f
/
keys
.
size
();
}
allIds
.
removeAll
(
referencedIds
);
System
.
out
.
println
(
referencedIds
.
size
()+
" referenced annotations"
);
System
.
out
.
println
(
allIds
.
size
()+
" unreferenced annotations"
);
win
.
host
.
historyManager
.
reset
();
cnt
=
0
;
for
(
int
id
:
allIds
)
{
link
.
getLink
().
removeMetaData
(
id
);
cnt
++;
progress
=
.
75
f
+
cnt
*.
25
f
/
allIds
.
size
();
}
}
catch
(
Exception
e
)
{
ErrorHandler
.
defaultHandler
.
submit
(
e
);}
}
public
Set
<
Integer
>
getAllReferencedMetaDataIds
(
DocExploreDataLink
link
)
throws
DataLinkException
{
Set
<
Integer
>
res
=
new
TreeSet
<
Integer
>();
List
<
Integer
>
bookIds
=
link
.
getLink
().
getAllBookIds
();
int
cnt
=
0
;
for
(
int
bookId
:
bookIds
)
{
Book
book
=
link
.
getBook
(
bookId
);
getMetaDataIds
(
book
,
res
);
for
(
int
pageNum
=
1
;
pageNum
<=
book
.
getLastPageNumber
();
pageNum
++)
{
Page
page
=
book
.
getPage
(
pageNum
);
getMetaDataIds
(
page
,
res
);
for
(
Region
region
:
page
.
getRegions
())
getMetaDataIds
(
region
,
res
);
page
.
unloadAll
();
}
book
.
unloadMetaData
();
cnt
++;
progress
=
cnt
*.
25
f
/
bookIds
.
size
();
}
cnt
=
0
;
Set
<
Integer
>
mdMds
=
new
TreeSet
<
Integer
>();
for
(
int
mdId
:
res
)
{
MetaData
md
=
link
.
getMetaData
(
mdId
);
getMetaDataIds
(
md
,
mdMds
);
cnt
++;
progress
=
.
25
f
+
cnt
*.
25
f
/
res
.
size
();
}
res
.
addAll
(
mdMds
);
return
res
;
}
static
void
getMetaDataIds
(
AnnotatedObject
object
,
Set
<
Integer
>
res
)
throws
DataLinkException
{
for
(
Map
.
Entry
<
MetaDataKey
,
List
<
MetaData
>>
mds
:
object
.
getMetaData
().
entrySet
())
for
(
MetaData
md
:
mds
.
getValue
())
res
.
add
(
md
.
getId
());
object
.
unloadMetaData
();
}
float
progress
=
0
;
public
float
getProgress
()
{
return
progress
;}
}
import
org.interreg.docexplore.manuscript.app.ManuscriptAppHost
;
import
org.interreg.docexplore.util.GuiUtils.ProgressRunnable
;
public
class
DataLinkCleaner
implements
ProgressRunnable
{
ManuscriptAppHost
host
;
public
DataLinkCleaner
(
ManuscriptAppHost
host
)
{
this
.
host
=
host
;
}
public
void
run
()
{
try
{
DocExploreDataLink
link
=
host
.
getLink
();
if
(
link
.
getLink
()
==
null
)
throw
new
Exception
(
Lang
.
s
(
"cleanLinkNoConnection"
));
Set
<
Integer
>
referencedIds
=
getAllReferencedMetaDataIds
(
link
);
Set
<
Integer
>
allIds
=
new
TreeSet
<
Integer
>();
Collection
<
MetaDataKey
>
keys
=
link
.
getAllKeys
();
int
cnt
=
0
;
for
(
MetaDataKey
key
:
keys
)
{
allIds
.
addAll
(
link
.
getLink
().
getMetaDataIds
(
key
.
getId
(),
null
));
cnt
++;
progress
=
.
5
f
+
cnt
*.
25
f
/
keys
.
size
();
}
allIds
.
removeAll
(
referencedIds
);
System
.
out
.
println
(
referencedIds
.
size
()+
" referenced annotations"
);
System
.
out
.
println
(
allIds
.
size
()+
" unreferenced annotations"
);
host
.
historyManager
.
reset
();
cnt
=
0
;
for
(
int
id
:
allIds
)
{
link
.
getLink
().
removeMetaData
(
id
);
cnt
++;
progress
=
.
75
f
+
cnt
*.
25
f
/
allIds
.
size
();
}
}
catch
(
Exception
e
)
{
ErrorHandler
.
defaultHandler
.
submit
(
e
);}
}
public
Set
<
Integer
>
getAllReferencedMetaDataIds
(
DocExploreDataLink
link
)
throws
DataLinkException
{
Set
<
Integer
>
res
=
new
TreeSet
<
Integer
>();
List
<
Integer
>
bookIds
=
link
.
getLink
().
getAllBookIds
();
int
cnt
=
0
;
for
(
int
bookId
:
bookIds
)
{
Book
book
=
link
.
getBook
(
bookId
);
getMetaDataIds
(
book
,
res
);
for
(
int
pageNum
=
1
;
pageNum
<=
book
.
getLastPageNumber
();
pageNum
++)
{
Page
page
=
book
.
getPage
(
pageNum
);
getMetaDataIds
(
page
,
res
);
for
(
Region
region
:
page
.
getRegions
())
getMetaDataIds
(
region
,
res
);
page
.
unloadAll
();
}
book
.
unloadMetaData
();
cnt
++;
progress
=
cnt
*.
25
f
/
bookIds
.
size
();
}
cnt
=
0
;
Set
<
Integer
>
mdMds
=
new
TreeSet
<
Integer
>();
for
(
int
mdId
:
res
)
{
MetaData
md
=
link
.
getMetaData
(
mdId
);
getMetaDataIds
(
md
,
mdMds
);
cnt
++;
progress
=
.
25
f
+
cnt
*.
25
f
/
res
.
size
();
}
res
.
addAll
(
mdMds
);
return
res
;
}
static
void
getMetaDataIds
(
AnnotatedObject
object
,
Set
<
Integer
>
res
)
throws
DataLinkException
{
for
(
Map
.
Entry
<
MetaDataKey
,
List
<
MetaData
>>
mds
:
object
.
getMetaData
().
entrySet
())
for
(
MetaData
md
:
mds
.
getValue
())
res
.
add
(
md
.
getId
());
object
.
unloadMetaData
();
}
float
progress
=
0
;
public
float
getProgress
()
{
return
progress
;}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment