use of com.solinia.solinia.Models.SoliniaClass in project solinia3-core by mixxit.
the class SoliniaClassFactory method CreateClass.
public static ISoliniaClass CreateClass(String classname, boolean adminonly) throws CoreStateInitException, SoliniaClassCreationException {
if (StateManager.getInstance().getConfigurationManager().getClassObj(classname.toUpperCase()) != null)
throw new SoliniaClassCreationException("Class already exists");
SoliniaClass classObj = new SoliniaClass();
classObj.setId(StateManager.getInstance().getConfigurationManager().getNextClassId());
classObj.setName(classname.toUpperCase());
classObj.setAdmin(adminonly);
StateManager.getInstance().getConfigurationManager().addClass(classObj);
return classObj;
}
use of com.solinia.solinia.Models.SoliniaClass in project solinia3-core by mixxit.
the class JsonClassRepository method commit.
@Override
public void commit() {
// TODO Auto-generated method stub
GsonBuilder gsonbuilder = new GsonBuilder();
// gsonbuilder.setPrettyPrinting();
Gson gson = gsonbuilder.create();
String jsonOutput = gson.toJson(classes.values(), new TypeToken<List<SoliniaClass>>() {
}.getType());
try {
File file = new File(filePath);
if (!file.exists())
file.createNewFile();
FileOutputStream fileOut = new FileOutputStream(file);
OutputStreamWriter outWriter = new OutputStreamWriter(fileOut);
outWriter.append(jsonOutput);
outWriter.close();
fileOut.close();
System.out.println("Commited " + classes.size() + " classes");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations