Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
e9fa7143
Commit
e9fa7143
authored
Mar 19, 2020
by
Benedikt Kleinmeier
Browse files
Merge branch 'master' into psychology
parents
19be831e
81c53181
Pipeline
#225268
passed with stages
in 126 minutes and 35 seconds
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
VadereGui/src/org/vadere/gui/projectview/control/ActionShowAboutDialog.java
View file @
e9fa7143
...
...
@@ -4,7 +4,7 @@ import javax.swing.*;
import
org.vadere.gui.components.utils.Messages
;
import
org.vadere.gui.components.utils.Resources
;
import
org.vadere.simulator.
projects.io.HashGenerator
;
import
org.vadere.simulator.
entrypoints.Version
;
import
java.awt.event.ActionEvent
;
import
java.text.MessageFormat
;
...
...
@@ -22,7 +22,7 @@ public class ActionShowAboutDialog extends AbstractAction {
public
void
actionPerformed
(
final
ActionEvent
event
)
{
String
text
=
""
;
text
+=
"<html>"
;
text
+=
"<font size =\"3\"><em>"
+
MessageFormat
.
format
(
Messages
.
getString
(
"ProjectView.version"
),
HashGenerator
.
releaseNumber
())
+
"</em></font><br>"
;
text
+=
"<font size =\"3\"><em>"
+
MessageFormat
.
format
(
Messages
.
getString
(
"ProjectView.version"
),
Version
.
releaseNumber
())
+
"</em></font><br>"
;
text
+=
"<br>"
;
text
+=
"<font size =\"3\">www.vadere.org</font><br>"
;
text
+=
"<font size =\"3\">"
+
MessageFormat
.
format
(
Messages
.
getString
(
"ProjectView.license.text"
),
"GNU Lesser General Public License (<em>LGPL</em>)."
)
+
"</font>"
;
...
...
VadereSimulator/src/org/vadere/simulator/entrypoints/Version.java
View file @
e9fa7143
package
org.vadere.simulator.entrypoints
;
import
org.jetbrains.annotations.NotNull
;
import
org.vadere.util.logging.Logger
;
import
java.io.InputStream
;
import
java.util.Arrays
;
import
java.util.Optional
;
import
java.util.Scanner
;
/**
* Versions in strict order from oldest to newest.
*/
public
enum
Version
{
UNDEFINED
(
"undefined"
),
NOT_A_RELEASE
(
"not a release"
),
V0_1
(
0
,
1
),
...
...
@@ -35,14 +36,16 @@ public enum Version {
V1_8
(
1
,
8
),
V1_9
(
1
,
9
),
V1_10
(
1
,
10
),
V1_11
(
1
,
11
)
,
;
V1_11
(
1
,
11
)
;
private
static
Logger
logger
=
Logger
.
getLogger
(
Version
.
class
);
private
String
label
;
private
int
major
;
private
int
minor
;
private
static
final
String
CURRENT_COMMIT_HASH_RESOURCE
=
"/current_commit_hash.txt"
;
Version
(
String
label
)
{
this
.
major
=
-
1
;
...
...
@@ -56,6 +59,35 @@ public enum Version {
this
.
label
=
major
+
"."
+
minor
;
}
public
static
String
commitHash
()
{
String
commitHash
=
getFirstStringTokenFromResource
(
CURRENT_COMMIT_HASH_RESOURCE
);
if
(
commitHash
==
null
)
{
commitHash
=
"topographyWarning: no commit hash"
;
logger
.
warn
(
"No commit hash found. The project will not contain a hash of the software source code."
);
}
return
commitHash
;
}
public
static
String
releaseNumber
()
{
return
latest
().
label
();
}
/* Read commit hash from file
*/
private
static
String
getFirstStringTokenFromResource
(
String
resource
)
{
final
InputStream
in
=
Version
.
class
.
getResourceAsStream
(
resource
);
if
(
in
!=
null
)
{
try
(
final
Scanner
scanner
=
new
Scanner
(
in
))
{
if
(
scanner
.
hasNext
())
{
return
scanner
.
next
();
}
}
}
return
null
;
}
public
String
label
()
{
return
label
;
}
...
...
VadereSimulator/src/org/vadere/simulator/entrypoints/cmd/VadereConsole.java
View file @
e9fa7143
...
...
@@ -199,7 +199,7 @@ public class VadereConsole {
.
setDefault
(
"func"
,
utilsSubCommand
);
misc
.
addArgument
(
"-i"
)
.
required
(
tru
e
)
.
required
(
fals
e
)
.
type
(
String
.
class
)
.
dest
(
"input"
)
.
help
(
"A input file or directory depending on called method."
);
...
...
VadereSimulator/src/org/vadere/simulator/entrypoints/cmd/commands/UtilsSubCommand.java
View file @
e9fa7143
...
...
@@ -5,6 +5,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.vadere.simulator.entrypoints.ScenarioFactory
;
import
org.vadere.simulator.entrypoints.Version
;
import
org.vadere.simulator.entrypoints.cmd.SubCommandRunner
;
import
org.vadere.simulator.models.potential.fields.IPotentialField
;
import
org.vadere.simulator.models.potential.fields.PotentialFieldDistancesBruteForce
;
...
...
@@ -37,7 +38,8 @@ public class UtilsSubCommand implements SubCommandRunner {
methods
.
put
(
"getHash"
,
Pair
.
of
(
"[-i: file, -o: ignored]"
,
this
::
getHash
));
methods
.
put
(
"binCache"
,
Pair
.
of
(
"[-i: file, -o: directory]"
,
this
::
calculateBinCache
));
methods
.
put
(
"txtCache"
,
Pair
.
of
(
"[-i: file, -o: directory]"
,
this
::
calculateTextCache
));
methods
.
put
(
"getVersion"
,
Pair
.
of
(
"returns version"
,
this
::
getVersion
));
methods
.
put
(
"getCommitHash"
,
Pair
.
of
(
"returns commit hash"
,
this
::
getCommitHash
));
}
public
String
[]
methodsString
(){
...
...
@@ -85,10 +87,22 @@ public class UtilsSubCommand implements SubCommandRunner {
* Return the hash used to check if a new cache value needed to be calculated.
*/
private
void
getHash
(
Namespace
ns
,
ArgumentParser
parser
)
throws
Exception
{
Scenario
scenario
=
createScenario
(
ns
.
getString
(
"input"
));
System
.
out
.
println
(
ScenarioCache
.
getHash
(
scenario
));
calculateCache
(
ns
,
parser
,
CacheType
.
TXT_CACHE
);
}
/**
* Returns the current version
*/
private
void
getVersion
(
Namespace
ns
,
ArgumentParser
parser
)
throws
Exception
{
System
.
out
.
println
(
Version
.
releaseNumber
());
}
private
void
getCommitHash
(
Namespace
ns
,
ArgumentParser
parser
)
throws
Exception
{
System
.
out
.
println
(
Version
.
commitHash
());
/* String filename = Resources.class.getResource("/current_commit_hash.txt").getFile();
String commit_hash = (new BufferedReader(new FileReader(filename))).readLine();
System.out.println(commit_hash); */
}
private
void
calculateBinCache
(
Namespace
ns
,
ArgumentParser
parser
)
throws
Exception
{
calculateCache
(
ns
,
parser
,
CacheType
.
BIN_CACHE
);
...
...
VadereSimulator/src/org/vadere/simulator/projects/io/HashGenerator.java
deleted
100644 → 0
View file @
19be831e
package
org.vadere.simulator.projects.io
;
import
org.vadere.simulator.entrypoints.Version
;
import
org.vadere.util.logging.Logger
;
import
java.io.InputStream
;
import
java.util.Scanner
;
public
class
HashGenerator
{
private
static
Logger
logger
=
Logger
.
getLogger
(
HashGenerator
.
class
);
private
static
final
String
CURRENT_COMMIT_HASH_RESOURCE
=
"/current_commit_hash.txt"
;
public
static
String
commitHash
()
{
String
commitHash
=
getFirstStringTokenFromResource
(
CURRENT_COMMIT_HASH_RESOURCE
);
if
(
commitHash
==
null
)
{
commitHash
=
"topographyWarning: no commit hash"
;
logger
.
warn
(
"No commit hash found. The project will not contain a hash of the software source code."
);
}
return
commitHash
;
}
public
static
String
releaseNumber
()
{
return
Version
.
latest
().
label
();
}
private
static
String
getFirstStringTokenFromResource
(
String
resource
)
{
final
InputStream
in
=
HashGenerator
.
class
.
getResourceAsStream
(
resource
);
if
(
in
!=
null
)
{
try
(
final
Scanner
scanner
=
new
Scanner
(
in
))
{
if
(
scanner
.
hasNext
())
{
return
scanner
.
next
();
}
}
}
return
null
;
}
}
\ No newline at end of file
VadereSimulator/src/org/vadere/simulator/projects/io/JsonConverter.java
View file @
e9fa7143
...
...
@@ -3,8 +3,8 @@ package org.vadere.simulator.projects.io;
import
java.io.IOException
;
import
java.util.List
;
import
org.vadere.simulator.entrypoints.Version
;
import
org.vadere.simulator.models.MainModel
;
import
org.vadere.simulator.projects.Domain
;
import
org.vadere.simulator.projects.Scenario
;
import
org.vadere.simulator.projects.ScenarioStore
;
import
org.vadere.simulator.projects.dataprocessing.DataProcessingJsonManager
;
...
...
@@ -99,9 +99,9 @@ public class JsonConverter {
private
static
void
serializeMeta
(
ObjectNode
node
,
boolean
commitHashIncluded
,
ScenarioStore
scenarioStore
)
{
node
.
put
(
"name"
,
scenarioStore
.
getName
());
node
.
put
(
"description"
,
scenarioStore
.
getDescription
());
node
.
put
(
"release"
,
HashGenerator
.
releaseNumber
());
node
.
put
(
"release"
,
Version
.
releaseNumber
());
if
(
commitHashIncluded
)
node
.
put
(
"commithash"
,
HashGenerator
.
commitHash
());
node
.
put
(
"commithash"
,
Version
.
commitHash
());
}
private
static
ObjectNode
serializeVadereNode
(
ScenarioStore
scenarioStore
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment