1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package com.rthoni.intellij.codefromds.dbo;
-
- import com.intellij.database.model.DasTable;
- import com.intellij.database.psi.DbDataSource;
- import com.intellij.database.util.DasUtil;
-
- import java.io.File;
- import java.util.List;
- import java.util.Vector;
- import java.util.stream.Collectors;
-
- /**
- * Created by robin on 11/15/16.
- */
- public class GenerateOptions {
-
- public GenerateOptions() {
- }
-
- public GenerateOptions(DbDataSource source) {
- _modelsPath = source.getProject().getBasePath() + File.separator + "Models";
- _dataSourceTemplatePath = source.getProject().getBasePath() + File.separator + "Templates" + File.separator + "DataSource.twig";
- _modelsTemplatePath = source.getProject().getBasePath() + File.separator + "Templates" + File.separator + "Models.twig";
- _configPath = source.getProject().getBasePath() + File.separator + "code-from-ds.json";
- _selection = new DataSourceSelection(source);
- _selection.setSource(source);
- final List<? extends DasTable> tables = DasUtil.getTables(source).toList();
- List<TableSelection> tableSelections = new Vector<>();
- for (DasTable table : tables) {
- TableSelection tableSelection = new TableSelection();
- tableSelection.setTable(table);
- tableSelection.setColumns(DasUtil.getColumns(table).toList().stream().map(c -> {
- ColumnSelection selection = new ColumnSelection();
- selection.setColumn(c);
- selection.setSelected(true);
- return selection;
- }).collect(Collectors.toList()));
- tableSelections.add(tableSelection);
- }
- _selection.setTables(tableSelections);
- }
-
- private DataSourceSelection _selection;
-
- private String _modelsPath;
-
- private String _dataSourceTemplatePath;
-
- private String _modelsTemplatePath;
-
- private String _configPath;
-
- public DataSourceSelection getSelection() {
- return _selection;
- }
-
- public void setSelection(DataSourceSelection selection) {
- _selection = selection;
- }
-
- public String getModelsPath() {
- return _modelsPath;
- }
-
- public void setModelsPath(String modelsPath) {
- _modelsPath = modelsPath;
- }
-
- public String getDataSourceTemplatePath() {
- return _dataSourceTemplatePath;
- }
-
- public void setDataSourceTemplatePath(String dataSourceTemplatePath) {
- _dataSourceTemplatePath = dataSourceTemplatePath;
- }
-
- public String getModelsTemplatePath() {
- return _modelsTemplatePath;
- }
-
- public void setModelsTemplatePath(String modelsTemplatePath) {
- _modelsTemplatePath = modelsTemplatePath;
- }
-
- public String getConfigPath() {
- return _configPath;
- }
-
- public void setConfigPath(String configPath) {
- _configPath = configPath;
- }
- }
|