-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#115) Implemented functions fetching from Postgres, rendering functi…
…ons from objects in DBD
- Loading branch information
Showing
10 changed files
with
342 additions
and
8 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/main/java/org/fusionsoft/database/mapping/dbd/DbdFunctionMapping.java
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,33 @@ | ||
/* | ||
* Copyright (C) 2018-2021 FusionSoft | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. | ||
* | ||
* See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
package org.fusionsoft.database.mapping.dbd; | ||
|
||
import com.amihaiemil.eoyaml.YamlMapping; | ||
import org.fusionsoft.database.mapping.fields.DbdFunctionFields; | ||
import org.fusionsoft.lib.yaml.YamlMappingHasKeys; | ||
|
||
public class DbdFunctionMapping extends YamlMappingHasKeys { | ||
|
||
public DbdFunctionMapping(final YamlMapping mapping) { | ||
super( | ||
mapping, | ||
DbdFunctionFields.OWNER, | ||
DbdFunctionFields.DDL, | ||
DbdFunctionFields.AGGREGATE | ||
); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...main/java/org/fusionsoft/database/mapping/dbd/ofobjects/DbdFunctionsMappingOfObjects.java
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,48 @@ | ||
/* | ||
* Copyright (C) 2018-2021 FusionSoft | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. | ||
* | ||
* See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
package org.fusionsoft.database.mapping.dbd.ofobjects; | ||
|
||
import org.fusionsoft.database.mapping.MappingOfRepresentative; | ||
import org.fusionsoft.database.mapping.dbd.DbdFunctionMapping; | ||
import org.fusionsoft.database.mapping.entries.UnwrapEntriesOfObjects; | ||
import org.fusionsoft.database.snapshot.DbObject; | ||
import org.fusionsoft.database.snapshot.Objects; | ||
import org.fusionsoft.database.snapshot.objects.ObjectType; | ||
import org.fusionsoft.database.snapshot.objects.filtered.ObjectsWithParentAndType; | ||
import org.fusionsoft.lib.yaml.YamlMappingOfEntries; | ||
|
||
public class DbdFunctionsMappingOfObjects extends YamlMappingOfEntries { | ||
|
||
public DbdFunctionsMappingOfObjects( | ||
final Objects objects, | ||
final DbObject<?> schema | ||
) { | ||
super( | ||
new UnwrapEntriesOfObjects<DbdFunctionMapping>( | ||
objects, | ||
new ObjectsWithParentAndType( | ||
schema, | ||
ObjectType.FUNCTION, | ||
objects | ||
), | ||
(objs, object) -> new DbdFunctionMapping( | ||
new MappingOfRepresentative(object) | ||
) | ||
) | ||
); | ||
} | ||
|
||
} |
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
38 changes: 38 additions & 0 deletions
38
src/main/java/org/fusionsoft/database/mapping/fields/DbdFunctionFields.java
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,38 @@ | ||
/* | ||
* Copyright (C) 2018-2021 FusionSoft | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. | ||
* | ||
* See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
package org.fusionsoft.database.mapping.fields; | ||
|
||
import org.cactoos.Text; | ||
|
||
public enum DbdFunctionFields implements Text { | ||
SCHEMA("schema"), | ||
OWNER("owner"), | ||
FUNCTION("function"), | ||
ARGUMENTS("arguments"), | ||
DDL("ddl"), | ||
AGGREGATE("aggregate"); | ||
|
||
private final String text; | ||
|
||
DbdFunctionFields(final String text) { | ||
this.text = text; | ||
} | ||
|
||
@Override | ||
public String asString() { | ||
return this.text; | ||
} | ||
} |
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
90 changes: 90 additions & 0 deletions
90
src/main/java/org/fusionsoft/database/snapshot/objects/dbms/FunctionOfResultSet.java
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,90 @@ | ||
/* | ||
* Copyright (C) 2018-2021 FusionSoft | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. | ||
* | ||
* See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
package org.fusionsoft.database.snapshot.objects.dbms; | ||
|
||
import java.sql.ResultSet; | ||
import org.fusionsoft.database.mapping.dbd.DbdFunctionMapping; | ||
import org.fusionsoft.database.mapping.entries.MultilineScalarEntry; | ||
import org.fusionsoft.database.mapping.entries.ScalarEntry; | ||
import org.fusionsoft.database.mapping.fields.DbdFunctionFields; | ||
import org.fusionsoft.database.snapshot.objects.ObjectType; | ||
import org.fusionsoft.database.snapshot.objects.SimpleDbObject; | ||
import org.fusionsoft.database.snapshot.objectsignature.FullObjectName; | ||
import org.fusionsoft.database.snapshot.objectsignature.SimpleObjectSignature; | ||
import org.fusionsoft.database.snapshot.query.Query; | ||
import org.fusionsoft.lib.text.TextOfResultSet; | ||
import org.fusionsoft.lib.yaml.MappingWithoutNullScalars; | ||
import org.fusionsoft.lib.yaml.YamlMappingOfEntries; | ||
|
||
/** | ||
* The type of that can be constructed of. | ||
* @since 0.1 | ||
*/ | ||
public class FunctionOfResultSet extends SimpleDbObject<DbdFunctionMapping> { | ||
|
||
public FunctionOfResultSet(final ResultSet rset, final Query<DbdFunctionFields> query) { | ||
super( | ||
new DbdFunctionMapping( | ||
new MappingWithoutNullScalars( | ||
new YamlMappingOfEntries( | ||
new ScalarEntry( | ||
DbdFunctionFields.OWNER, | ||
new TextOfResultSet( | ||
query.outcomeFor(DbdFunctionFields.OWNER), | ||
rset | ||
) | ||
), | ||
new ScalarEntry( | ||
DbdFunctionFields.ARGUMENTS, | ||
new TextOfResultSet( | ||
query.outcomeFor(DbdFunctionFields.ARGUMENTS), | ||
rset | ||
) | ||
), | ||
new ScalarEntry( | ||
DbdFunctionFields.AGGREGATE, | ||
new TextOfResultSet( | ||
query.outcomeFor(DbdFunctionFields.AGGREGATE), | ||
rset | ||
) | ||
), | ||
new MultilineScalarEntry( | ||
DbdFunctionFields.DDL, | ||
new TextOfResultSet( | ||
query.outcomeFor(DbdFunctionFields.DDL), | ||
rset | ||
) | ||
) | ||
) | ||
) | ||
), | ||
new SimpleObjectSignature( | ||
new FullObjectName( | ||
new TextOfResultSet( | ||
query.outcomeFor(DbdFunctionFields.SCHEMA), | ||
rset | ||
), | ||
new TextOfResultSet( | ||
query.outcomeFor(DbdFunctionFields.FUNCTION), | ||
rset | ||
) | ||
), | ||
ObjectType.FUNCTION | ||
) | ||
); | ||
} | ||
|
||
} |
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
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.