Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
beamline
Framework
Commits
47315b6b
Commit
47315b6b
authored
3 years ago
by
Andrea Burattin
Browse files
Options
Downloads
Patches
Plain Diff
Added source from CSV files
parent
c4f079c4
No related branches found
Branches containing commit
Tags
0.0.3
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pom.xml
+6
-1
6 additions, 1 deletion
pom.xml
src/main/java/beamline/sources/CSVLogSource.java
+75
-0
75 additions, 0 deletions
src/main/java/beamline/sources/CSVLogSource.java
src/main/java/beamline/sources/XesLogSource.java
+1
-1
1 addition, 1 deletion
src/main/java/beamline/sources/XesLogSource.java
with
82 additions
and
2 deletions
pom.xml
+
6
−
1
View file @
47315b6b
...
...
@@ -4,7 +4,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
beamline
</groupId>
<artifactId>
framework
</artifactId>
<version>
0.0.
2
</version>
<version>
0.0.
3
</version>
<properties>
<maven.compiler.source>
11
</maven.compiler.source>
...
...
@@ -59,5 +59,10 @@
<artifactId>
graphviz
</artifactId>
<version>
0.0.2
</version>
</dependency>
<dependency>
<groupId>
com.opencsv
</groupId>
<artifactId>
opencsv
</artifactId>
<version>
5.6
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/beamline/sources/CSVLogSource.java
0 → 100644
+
75
−
0
View file @
47315b6b
package
beamline.sources
;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
org.deckfour.xes.extension.std.XConceptExtension
;
import
org.deckfour.xes.factory.XFactory
;
import
org.deckfour.xes.factory.XFactoryNaiveImpl
;
import
org.deckfour.xes.model.XEvent
;
import
org.deckfour.xes.model.XTrace
;
import
com.opencsv.CSVParser
;
import
com.opencsv.CSVReader
;
import
com.opencsv.CSVReaderBuilder
;
import
io.reactivex.rxjava3.annotations.NonNull
;
import
io.reactivex.rxjava3.core.Observable
;
import
io.reactivex.rxjava3.core.ObservableEmitter
;
import
io.reactivex.rxjava3.core.ObservableOnSubscribe
;
public
class
CSVLogSource
implements
XesSource
{
private
static
XFactory
xesFactory
=
new
XFactoryNaiveImpl
();
private
CSVReader
csvReader
;
private
String
filename
;
private
int
caseIdColumn
;
private
int
activityNameColumn
;
private
CSVParser
parser
;
public
CSVLogSource
(
String
filename
,
int
caseIdColumn
,
int
activityNameColumn
,
CSVParser
parser
)
throws
IOException
{
this
.
filename
=
filename
;
this
.
caseIdColumn
=
caseIdColumn
;
this
.
activityNameColumn
=
activityNameColumn
;
this
.
parser
=
parser
;
}
public
CSVLogSource
(
String
filename
,
int
caseIdColumn
,
int
activityNameColumn
)
throws
IOException
{
this
(
filename
,
caseIdColumn
,
activityNameColumn
,
null
);
}
@Override
public
Observable
<
XTrace
>
getObservable
()
{
return
Observable
.
create
(
new
ObservableOnSubscribe
<
XTrace
>()
{
@Override
public
void
subscribe
(
@NonNull
ObservableEmitter
<
@NonNull
XTrace
>
emitter
)
throws
Throwable
{
String
[]
line
;
while
((
line
=
csvReader
.
readNext
())
!=
null
)
{
XTrace
eventWrapper
=
xesFactory
.
createTrace
();
XEvent
newEvent
=
xesFactory
.
createEvent
();
XConceptExtension
.
instance
().
assignName
(
eventWrapper
,
line
[
caseIdColumn
]);
XConceptExtension
.
instance
().
assignName
(
newEvent
,
line
[
activityNameColumn
]);
for
(
int
i
=
0
;
i
<
line
.
length
;
i
++)
{
String
attributeName
=
"attribute_"
+
i
;
newEvent
.
getAttributes
().
put
(
attributeName
,
xesFactory
.
createAttributeLiteral
(
attributeName
,
line
[
i
],
null
));
}
eventWrapper
.
add
(
newEvent
);
emitter
.
onNext
(
eventWrapper
);
}
}
});
}
@Override
public
void
prepare
()
throws
Exception
{
Reader
reader
=
Files
.
newBufferedReader
(
Paths
.
get
(
filename
));
if
(
parser
==
null
)
{
csvReader
=
new
CSVReader
(
reader
);
}
else
{
csvReader
=
new
CSVReaderBuilder
(
reader
).
withCSVParser
(
parser
).
build
();
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/beamline/sources/XesLogSource.java
+
1
−
1
View file @
47315b6b
...
...
@@ -25,7 +25,7 @@ import io.reactivex.rxjava3.core.ObservableOnSubscribe;
public
class
XesLogSource
implements
XesSource
{
private
static
XFactory
xesFactory
=
new
XFactoryNaiveImpl
();
private
static
XFactory
xesFactory
=
new
XFactoryNaiveImpl
();
private
String
fileName
;
private
XLog
log
;
...
...
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