-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start implementing usage of to.science.core
- Loading branch information
Showing
4 changed files
with
397 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* | ||
*/ | ||
package helper; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.StringReader; | ||
|
||
import org.json.JSONObject; | ||
|
||
import actions.Read; | ||
import models.Node; | ||
import to.science.core.modelx.mapper.AmbMapperImpl; | ||
|
||
/** | ||
* @author aquast | ||
* | ||
*/ | ||
public class AmbMappingHelper { | ||
|
||
AmbMapperImpl ambMapper = new AmbMapperImpl(); | ||
|
||
/** | ||
* Get a to.science JSONObject from lrmiData within a specific node | ||
* | ||
* @param node | ||
* @return | ||
*/ | ||
public JSONObject getJSONObjectFromAmb(Node node) { | ||
JSONObject tosModel = new JSONObject(); | ||
|
||
Read read = new Read(); | ||
String currentLrmiContent = read.readLrmiData(node); | ||
StringReader ambReader = new StringReader(currentLrmiContent); | ||
JSONObject ambObject = parseReader(ambReader); | ||
tosModel = ambMapper.getTosJSONObject(ambObject); | ||
|
||
return tosModel; | ||
} | ||
|
||
/** | ||
* @param ambReader | ||
* @return | ||
*/ | ||
private JSONObject parseReader(StringReader ambReader) { | ||
JSONObject ambJSONObj = new JSONObject(); | ||
|
||
try { | ||
BufferedReader bReader = new BufferedReader(ambReader); | ||
StringBuilder jsonStringBuilder = new StringBuilder(); | ||
|
||
String inputStr; | ||
while ((inputStr = bReader.readLine()) != null) | ||
jsonStringBuilder.append(inputStr); | ||
ambJSONObj = new JSONObject(jsonStringBuilder.toString()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
return ambJSONObj; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.