4
4
import static org .junit .Assert .assertTrue ;
5
5
6
6
import java .io .File ;
7
+ import java .io .IOException ;
7
8
8
9
import javax .xml .stream .XMLStreamException ;
9
10
11
+ import org .insilico .vissim .sbscl .factory .SimulationResult ;
10
12
import org .insilico .vissim .sbscl .simulation .SimulationType ;
11
13
import org .jlibsedml .Libsedml ;
14
+ import org .sbml .jsbml .Model ;
12
15
import org .sbml .jsbml .SBMLReader ;
13
16
import org .simulator .omex .OMEXArchive ;
14
17
15
18
/**
16
- * Some basic utilities which need to be in helping project (for shifting operations or
17
- * other reasons), which are not toolkit dependent.
19
+ * Some basic utilities which need to be in helping project (for shifting
20
+ * operations or other reasons), which are not toolkit dependent.
18
21
*/
19
22
public class Utils {
20
23
21
24
/**
22
25
* Provides the type of corresponding simulation
23
26
*
24
27
* <p>
25
- * Every simulation is eponymous to the type of the file specified.
26
- * e.g SimulationType.SEDML is a simulation described with SED-ML file.
28
+ * Every simulation is eponymous to the type of the file specified. e.g
29
+ * SimulationType.SEDML is a simulation described with SED-ML file.
27
30
*
28
31
* @param path absolute path to the file
29
32
* @return {@link SimulationType}
30
- * * /
33
+ */
31
34
public SimulationType getSimulationType (String path ) {
32
- if (Libsedml . isSEDML ( new File ( path )))
33
- return SimulationType .SEDML ;
34
- if ( isOMEXArchiv ( path )) {
35
- return SimulationType . OMEX ;
36
- }
37
- if (isSBML (path )) {
38
- return SimulationType .SBML ;
39
- }
35
+ if (isSBML ( path )) {
36
+ return SimulationType .SBML ;
37
+ }
38
+ if ( Libsedml . isSEDML ( new File ( path )))
39
+ return SimulationType . SEDML ;
40
+ if (isOMEXArchiv (path )) {
41
+ return SimulationType .OMEX ;
42
+ }
40
43
return SimulationType .UNKNOWN_ENTITY ;
41
44
}
42
45
43
46
/**
44
- * Checks if provided file is a OMEXArchiv (combination of SED-ML
45
- * and SBML file with additional data)
47
+ * Checks if provided file is a OMEXArchiv (combination of SED-ML and SBML file
48
+ * with additional data)
46
49
*
47
50
* @param path absolute path to the file
48
- * * /
51
+ */
49
52
private boolean isOMEXArchiv (String path ) {
50
53
OMEXArchive archive ;
51
54
try {
@@ -59,20 +62,21 @@ private boolean isOMEXArchiv(String path) {
59
62
return Boolean .FALSE ;
60
63
}
61
64
}
62
-
65
+
63
66
/**
64
- * Checks if provided file is a SBML file
65
- * XXX: more efficient check should be considered
67
+ * Checks if provided file is a SBML file XXX: more efficient check should be
68
+ * considered
66
69
*
67
70
* @param path absolute path to the file
68
- * * /
71
+ */
69
72
private boolean isSBML (String path ) {
70
73
try {
71
74
// this check should be changed
72
75
// reading file to define file type is inefficient
73
- SBMLReader .read (path );
76
+ SBMLReader reader = new SBMLReader ();
77
+ assertNotNull (reader .readSBML (path ).getModel ());
74
78
return Boolean .TRUE ;
75
- } catch (XMLStreamException e ) {
79
+ } catch (XMLStreamException | IOException e ) {
76
80
return Boolean .FALSE ;
77
81
}
78
82
}
0 commit comments