Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
ma-impl
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eccochu
ma-impl
Commits
92c4042c
Commit
92c4042c
authored
9 years ago
by
Eike Cochu
Browse files
Options
Downloads
Patches
Plain Diff
updated cmd lib in preparation for usage in rest project
parent
58d486c2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vipra-cmd/src/main/java/de/vipra/cmd/option/DeleteCommand.java
+13
-5
13 additions, 5 deletions
...-cmd/src/main/java/de/vipra/cmd/option/DeleteCommand.java
vipra-cmd/src/main/java/de/vipra/cmd/option/ImportCommand.java
+12
-3
12 additions, 3 deletions
...-cmd/src/main/java/de/vipra/cmd/option/ImportCommand.java
with
25 additions
and
8 deletions
vipra-cmd/src/main/java/de/vipra/cmd/option/DeleteCommand.java
+
13
−
5
View file @
92c4042c
...
...
@@ -28,11 +28,18 @@ public class DeleteCommand implements Command {
private
DatabaseService
<
ProcessedArticle
>
dbArticles
;
private
Filebase
filebase
;
public
DeleteCommand
(
String
[]
strings
)
{
addIds
(
strings
);
/**
* Creates a new delete command. Use {@link DeleteCommand#run()} to run this
* command.
*
* @param ids
* array of ids to be used for deletion.
*/
public
DeleteCommand
(
String
[]
ids
)
{
addIds
(
ids
);
}
p
rivate
void
addIds
(
String
[]
strings
)
{
p
ublic
void
addIds
(
String
[]
strings
)
{
for
(
String
str
:
strings
)
{
if
(
str
.
contains
(
File
.
pathSeparator
))
{
String
[]
parts
=
str
.
split
(
File
.
pathSeparator
);
...
...
@@ -42,7 +49,7 @@ public class DeleteCommand implements Command {
}
}
void
deleteEntry
(
String
id
)
throws
ExecutionException
{
public
void
deleteEntry
(
String
id
)
throws
ExecutionException
{
ArrayList
<
Exception
>
errors
=
new
ArrayList
<>();
try
{
...
...
@@ -71,7 +78,8 @@ public class DeleteCommand implements Command {
public
void
run
()
throws
ExecutionException
{
try
{
config
=
Config
.
getConfig
();
dbArticles
=
DatabaseService
.
getDatabaseService
(
config
,
Constants
.
Collection
.
ARTICLES
,
ProcessedArticle
.
class
);
dbArticles
=
DatabaseService
.
getDatabaseService
(
config
,
Constants
.
Collection
.
ARTICLES
,
ProcessedArticle
.
class
);
filebase
=
Filebase
.
getFilebase
(
config
);
}
catch
(
IOException
|
FilebaseException
|
ConfigException
e
)
{
throw
new
ExecutionException
(
e
);
...
...
This diff is collapsed.
Click to expand it.
vipra-cmd/src/main/java/de/vipra/cmd/option/ImportCommand.java
+
12
−
3
View file @
92c4042c
...
...
@@ -52,6 +52,15 @@ public class ImportCommand implements Command {
private
Processor
preprocessor
;
private
LDAAnalyzer
analyzer
;
/**
* Import command to import articles into the database, do topic modeling
* and save everything. Use {@link ImportCommand#run()} to execute this
* command.
*
* @param paths
* Paths to all *.json files containing artiles or folders
* containing *.json files. Not recursive.
*/
public
ImportCommand
(
String
[]
paths
)
{
addPaths
(
paths
);
}
...
...
@@ -62,13 +71,13 @@ public class ImportCommand implements Command {
}
}
p
rivate
void
addPaths
(
File
[]
paths
)
{
p
ublic
void
addPaths
(
File
[]
paths
)
{
for
(
int
i
=
0
;
i
<
paths
.
length
;
i
++)
{
addPath
(
paths
[
i
]);
}
}
p
rivate
void
addPath
(
File
file
)
{
p
ublic
void
addPath
(
File
file
)
{
if
(
file
.
isFile
())
{
files
.
add
(
file
);
}
else
if
(
file
.
isDirectory
())
{
...
...
@@ -90,7 +99,7 @@ public class ImportCommand implements Command {
* @return
* @throws ImportException
*/
void
importArticle
(
JSONObject
obj
)
throws
ImportException
{
private
void
importArticle
(
JSONObject
obj
)
throws
ImportException
{
out
.
debug
(
"importing \""
+
StringUtils
.
ellipsize
(
obj
.
get
(
"title"
).
toString
(),
80
)
+
"\""
);
ProcessedArticle
article
=
new
ProcessedArticle
();
article
.
fromJSON
(
obj
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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