Easter cleaning git
This commit is contained in:
commit
d0529bfadf
500 changed files with 116670 additions and 0 deletions
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.gdxapp4d.app.mmdoc;
|
||||
|
||||
import org.osgi.service.component.annotations.Activate;
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
import org.osgi.service.component.annotations.Deactivate;
|
||||
import org.osgi.service.component.annotations.Reference;
|
||||
|
||||
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxBootArgs;
|
||||
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxLog;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4DeskAppService;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppLauncher;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppMenuSection;
|
||||
import ᒢᐩᐩ.ᔆʸᔆᐪᓫᔿ.ᒃᣔᒃᓫᒻ.ᑊᐣᓑᖮᐪᔆ.DuytsDocAuthor注;
|
||||
|
||||
@Component
|
||||
@DuytsDocAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||
public class MMDocComponent {
|
||||
|
||||
@Reference
|
||||
private SystemGdxLog log;
|
||||
|
||||
@Reference
|
||||
private VrGem4DeskAppService deskAppService;
|
||||
|
||||
@Reference
|
||||
private SystemGdxBootArgs bootArgs;
|
||||
|
||||
private final DeskAppLauncher launcher;
|
||||
|
||||
public MMDocComponent() {
|
||||
launcher = new DeskAppLauncher(DeskAppMenuSection.PROGRAMMING, "MMDoc", () -> new MMDocDeskApp(bootArgs.getFileChooser()));
|
||||
}
|
||||
|
||||
@Activate
|
||||
void open() {
|
||||
log.debug(this, SystemGdxLog.ACTIVATE);
|
||||
deskAppService.installDeskApp(launcher);
|
||||
}
|
||||
|
||||
@Deactivate
|
||||
void close() {
|
||||
log.debug(this, SystemGdxLog.DEACTIVATE);
|
||||
deskAppService.removeDeskApp(launcher);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,191 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.gdxapp4d.app.mmdoc;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.apache.metamodel.DataContext;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
|
||||
import imgui.ImGui;
|
||||
import imgui.flag.ImGuiTableFlags;
|
||||
import imgui.type.ImString;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.AbstractDeskApp;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppContourSection;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppRenderer;
|
||||
import net.spookygames.gdx.nativefilechooser.NativeFileChooser;
|
||||
import net.spookygames.gdx.nativefilechooser.NativeFileChooserCallback;
|
||||
import net.spookygames.gdx.nativefilechooser.NativeFileChooserConfiguration;
|
||||
import ᒢᐩᐩ.ᔆʸᔆᐪᓫᔿ.ᒃᣔᒃᓫᒻ.ᑊᐣᓑᖮᐪᔆ.DuytsDocAuthor注;
|
||||
|
||||
@DuytsDocAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||
public class MMDocDeskApp extends AbstractDeskApp implements DeskAppRenderer {
|
||||
|
||||
private final NativeFileChooser fileChooser;
|
||||
private final NativeFileChooserConfiguration fileChooserConfig;
|
||||
private final MMDocManager docManager;
|
||||
private final ImString dbHost = new ImString();
|
||||
private final ImString dbName = new ImString();
|
||||
private final ImString dbUser = new ImString();
|
||||
private final ImString dbPass = new ImString();
|
||||
private final ImString docTarget = new ImString();
|
||||
private String result = "";
|
||||
|
||||
public MMDocDeskApp(NativeFileChooser fileChooser) {
|
||||
this.fileChooser = fileChooser;
|
||||
fileChooserConfig = new NativeFileChooserConfiguration();
|
||||
fileChooserConfig.directory = Gdx.files.absolute(System.getProperty("user.home"));
|
||||
fileChooserConfig.title = "Choose file";
|
||||
docManager = new MMDocManager();
|
||||
docManager.loadDrivers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
docManager.getDataStore().clearAndCloseAllSafe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
getContours().setTitle("MMDoc");
|
||||
getContours().registrateContour(DeskAppContourSection.MAIN, this);
|
||||
|
||||
dbHost.set("localhost");
|
||||
dbName.set("test");
|
||||
dbUser.set("user");
|
||||
dbPass.set("pass");
|
||||
docTarget.set("target/mm-doc");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
ImGui.inputText("docTarget", docTarget);
|
||||
ImGui.separator();
|
||||
ImGui.inputText("dbHost", dbHost);
|
||||
ImGui.inputText("dbName", dbName);
|
||||
ImGui.inputText("dbUser", dbUser);
|
||||
ImGui.inputText("dbPass", dbPass);
|
||||
ImGui.separator();
|
||||
|
||||
if (ImGui.button("Add XML")) {
|
||||
fileChooser.chooseFile(fileChooserConfig, NativeFileChooserCallbackAdapter.onFileChosen(v -> {
|
||||
docManager.addDocModelXml(v.file());
|
||||
result = "Added XML file";
|
||||
}));
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("Add CSV")) {
|
||||
fileChooser.chooseFile(fileChooserConfig, NativeFileChooserCallbackAdapter.onFileChosen(v -> {
|
||||
docManager.addDocModelCsv(v.file());
|
||||
result = "Added CSV file";
|
||||
}));
|
||||
}
|
||||
try {
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("Add Mariadb")) {
|
||||
docManager.addDocModelJdbcMy(dbHost.get(), dbName.get(), dbUser.get(), dbPass.get());
|
||||
result = "Added MariaDB";
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("Add Postgresql")) {
|
||||
docManager.addDocModelJdbcPg(dbHost.get(), dbName.get(), dbUser.get(), dbPass.get());
|
||||
result = "Added Postgresqk DB";
|
||||
}
|
||||
if (ImGui.button("Generate")) {
|
||||
docManager.generate(new File(docTarget.get()));
|
||||
result = "done";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result = e.getMessage();
|
||||
}
|
||||
ImGui.sameLine();
|
||||
ImGui.text("Result: "+result);
|
||||
|
||||
ImGui.text("DataSources:");
|
||||
int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV | ImGuiTableFlags.Resizable;
|
||||
ImGui.beginTable("DataSources", 4, flags);
|
||||
ImGui.tableSetupColumn("Id");
|
||||
ImGui.tableSetupColumn("Type");
|
||||
ImGui.tableSetupColumn("TableCount");
|
||||
ImGui.tableSetupColumn("Remove");
|
||||
ImGui.tableHeadersRow();
|
||||
|
||||
int i=1;
|
||||
String removeId = null;
|
||||
for (Entry<String,DataContext> data:docManager.getDataStore().entrySet()) {
|
||||
ImGui.pushID(i);
|
||||
ImGui.tableNextRow();
|
||||
ImGui.tableNextColumn();
|
||||
ImGui.text(data.getKey());
|
||||
ImGui.tableNextColumn();
|
||||
ImGui.text(data.getValue().getClass().getSimpleName());
|
||||
ImGui.tableNextColumn();
|
||||
ImGui.text(Integer.toString(data.getValue().getDefaultSchema().getTableCount()));
|
||||
ImGui.tableNextColumn();
|
||||
if (ImGui.smallButton("Remove")) {
|
||||
removeId = data.getKey();
|
||||
}
|
||||
ImGui.popID();
|
||||
i++;
|
||||
}
|
||||
ImGui.endTable();
|
||||
|
||||
if (removeId != null) {
|
||||
docManager.getDataStore().removeDataContext(removeId);
|
||||
}
|
||||
}
|
||||
|
||||
static class NativeFileChooserCallbackAdapter implements NativeFileChooserCallback {
|
||||
|
||||
@Override
|
||||
public void onFileChosen(FileHandle file) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancellation() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception exception) {
|
||||
}
|
||||
|
||||
static NativeFileChooserCallbackAdapter onFileChosen(Consumer<FileHandle> eater) {
|
||||
return new NativeFileChooserCallbackAdapter() {
|
||||
@Override
|
||||
public void onFileChosen(FileHandle file) {
|
||||
eater.accept(file);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.gdxapp4d.app.mmdoc;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.metamodel.csv.CsvDataContext;
|
||||
import org.eobjects.metamodel.doc.DocModelDataStore;
|
||||
import org.eobjects.metamodel.doc.DocModelWriter;
|
||||
import org.apache.metamodel.jdbc.JdbcDataContext;
|
||||
import org.apache.metamodel.xml.XmlDomDataContext;
|
||||
|
||||
public class MMDocManager {
|
||||
|
||||
private final DocModelDataStore dms = new DocModelDataStore();
|
||||
|
||||
public void loadDrivers() { // mariadb has to be forced to load in ogsi bundle, pg works fine(no osgi info)
|
||||
try {
|
||||
Class.forName(org.postgresql.Driver.class.getName());
|
||||
//Class.forName(org.h2.Driver.class.getName());
|
||||
//Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver.class.getName());
|
||||
Class.forName(org.mariadb.jdbc.Driver.class.getName());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public DocModelDataStore getDataStore() {
|
||||
return dms;
|
||||
}
|
||||
|
||||
public void generate(File targetPath) throws Exception {
|
||||
try {
|
||||
DocModelWriter writer = new DocModelWriter(dms);
|
||||
writer.writeModelDoc(targetPath);
|
||||
} finally {
|
||||
//dms.clearAndCloseAllSafe();
|
||||
}
|
||||
}
|
||||
|
||||
public void addDocModelXml(File file) {
|
||||
dms.addDataContext("xml-"+file.getName(),new XmlDomDataContext(file,false));
|
||||
}
|
||||
|
||||
public void addDocModelCsv(File file) {
|
||||
dms.addDataContext("csv-"+file.getName(),new CsvDataContext(file));
|
||||
}
|
||||
|
||||
public void addDocModelJdbcMy(String host, String dbName, String user, String pass) throws SQLException {
|
||||
dms.addDataContext("my-"+dbName,new JdbcDataContext(DriverManager.getConnection("jdbc:mariadb://"+host+"/"+dbName,user,pass)));
|
||||
}
|
||||
|
||||
public void addDocModelJdbcPg(String host, String dbName, String user, String pass) throws SQLException {
|
||||
dms.addDataContext("pg-"+dbName,new JdbcDataContext(DriverManager.getConnection("jdbc:postgresql://"+host+"/"+dbName,user,pass)));
|
||||
}
|
||||
|
||||
public void addDocModelJdbcMs(String host, String dbName, String user, String pass) throws SQLException {
|
||||
dms.addDataContext("ms-"+dbName,new JdbcDataContext(DriverManager.getConnection("jdbc:sqlserver://"+host+";databaseName="+dbName,user,pass)));
|
||||
}
|
||||
|
||||
// @SuppressWarnings("deprecation")
|
||||
// public void addDocModelMongoDB(String host, String dbName, String user, String pass) {
|
||||
// Mongo mongo = new Mongo(new ServerAddress(host),new MongoOptions());
|
||||
// dms.addDataContext("mongo-"+dbName,new MongoDbDataContext(mongo.getDB(dbName)));
|
||||
// }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue