Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NeoSuit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christian Wulf
NeoSuit
Commits
ee5defdb
Commit
ee5defdb
authored
9 years ago
by
Dean Jonas Finkes
Browse files
Options
Downloads
Patches
Plain Diff
added matcher
parent
9d6962c4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
NeoSuit/src/main/java/controller/Matcher.java
+60
-0
60 additions, 0 deletions
NeoSuit/src/main/java/controller/Matcher.java
with
60 additions
and
0 deletions
NeoSuit/src/main/java/controller/Matcher.java
0 → 100644
+
60
−
0
View file @
ee5defdb
package
controller
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
javax.xml.parsers.DocumentBuilder
;
import
javax.xml.parsers.DocumentBuilderFactory
;
import
javax.xml.parsers.ParserConfigurationException
;
import
org.neo4j.graphdb.GraphDatabaseService
;
import
org.neo4j.graphdb.Result
;
import
org.neo4j.graphdb.Transaction
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Element
;
import
org.xml.sax.SAXException
;
import
java2sdg.db.Neo4Jdb
;
public
class
Matcher
{
public
ArrayList
<
String
>
applyCP
(
String
pathToDB
,
String
pathToPatternFolder
)
throws
ParserConfigurationException
,
SAXException
,
IOException
{
File
dir
=
new
File
(
pathToPatternFolder
);
ArrayList
<
String
>
matchingCPs
=
new
ArrayList
<
String
>();
if
(
dir
.
isDirectory
())
{
File
[]
patterns
=
dir
.
listFiles
();
if
(
patterns
.
length
>
0
)
{
DocumentBuilderFactory
dbFactory
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilder
dBuilder
=
dbFactory
.
newDocumentBuilder
();
Document
doc
;
Element
root
;
GraphDatabaseService
db
=
new
Neo4Jdb
(
pathToDB
).
getGraphDatabaseService
();
for
(
int
i
=
0
;
i
<
patterns
.
length
;
i
++)
{
doc
=
dBuilder
.
parse
(
patterns
[
i
]);
doc
.
normalize
();
root
=
doc
.
getDocumentElement
();
String
name
=
root
.
getElementsByTagName
(
"name"
).
item
(
0
).
getTextContent
();
String
cpQuery
=
root
.
getElementsByTagName
(
"cp"
).
item
(
0
).
getTextContent
();
try
(
Transaction
tx
=
db
.
beginTx
();
Result
result
=
db
.
execute
(
cpQuery
))
{
if
(
result
.
hasNext
())
{
matchingCPs
.
add
(
name
);
}
tx
.
success
();
}
}
db
.
shutdown
();
}
}
return
matchingCPs
;
}
}
\ No newline at end of file
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