-
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.
(#106) Created skeleton and some implementations of data-related classes
- Loading branch information
Showing
26 changed files
with
1,125 additions
and
35 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/org/fusionsoft/database/mapping/dbd/DbdDataMapping.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,32 @@ | ||
/* | ||
* 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.lib.yaml.YamlMappingEnvelope; | ||
|
||
public class DbdDataMapping extends YamlMappingEnvelope { | ||
|
||
/** | ||
* Instantiates a new Yaml mapping envelope. | ||
* @param mapping The YamlMapping to be encapsulated. | ||
*/ | ||
public DbdDataMapping(final YamlMapping mapping) { | ||
super(mapping); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/org/fusionsoft/database/mapping/dbd/ofobjects/DbdColumnsOfTable.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,47 @@ | ||
/* | ||
* 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 com.amihaiemil.eoyaml.StrictYamlMapping; | ||
import org.cactoos.iterable.IterableEnvelope; | ||
import org.cactoos.iterable.IterableOf; | ||
import org.cactoos.iterator.Mapped; | ||
import org.fusionsoft.database.mapping.dbd.DbdColumnMapping; | ||
import org.fusionsoft.database.mapping.dbd.DbdTableMapping; | ||
import org.fusionsoft.database.mapping.fields.DbdTableFields; | ||
import org.fusionsoft.database.snapshot.DbObject; | ||
|
||
public class DbdColumnsOfTable extends IterableEnvelope<DbdColumnMapping> { | ||
|
||
public DbdColumnsOfTable(final DbObject<DbdTableMapping> object) { | ||
this(object.asYaml()); | ||
} | ||
|
||
public DbdColumnsOfTable(final DbdTableMapping mapping) { | ||
super( | ||
new IterableOf<>( | ||
() -> new Mapped<>( | ||
x -> new DbdColumnMapping(x.asMapping()), | ||
new StrictYamlMapping(mapping) | ||
.value(DbdTableFields.COLUMNS.asString()) | ||
.asSequence() | ||
.iterator() | ||
) | ||
) | ||
); | ||
} | ||
|
||
} |
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
41 changes: 41 additions & 0 deletions
41
src/main/java/org/fusionsoft/database/mapping/value/IuTypeValues.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,41 @@ | ||
/* | ||
* 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.value; | ||
|
||
import org.cactoos.Text; | ||
|
||
public enum IuTypeValues implements Text { | ||
NUMBER("number"), | ||
STRING("sting"), | ||
DATE("date"), | ||
BOOLEAN("boolean"), | ||
BINARY("binary"), | ||
ARRAY("array"), | ||
JSON("json"), | ||
NATIVE("native"); | ||
|
||
private final String text; | ||
|
||
IuTypeValues(final String text) { | ||
this.text = text; | ||
} | ||
|
||
@Override | ||
public String asString() { | ||
return this.text; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/org/fusionsoft/database/snapshot/data/ArrayRow.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,42 @@ | ||
/* | ||
* 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.data; | ||
|
||
import org.cactoos.Text; | ||
import org.cactoos.text.TextOf; | ||
|
||
public class ArrayRow implements Row { | ||
|
||
private final long num; | ||
|
||
private final String[] array; | ||
|
||
public ArrayRow(final long num, final String[] array) { | ||
this.num = num; | ||
this.array = array; | ||
} | ||
|
||
@Override | ||
public Text textOf(final Column column) { | ||
return new TextOf(array[column.order().intValue()]); | ||
} | ||
|
||
@Override | ||
public long number() { | ||
return this.num; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/fusionsoft/database/snapshot/data/Column.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,25 @@ | ||
/* | ||
* 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.data; | ||
|
||
import org.cactoos.Text; | ||
|
||
public interface Column { | ||
Text name(); | ||
Number order(); | ||
ValueFormat format(); | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/fusionsoft/database/snapshot/data/ColumnOfDbdColumnMapping.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,39 @@ | ||
/* | ||
* 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.data; | ||
|
||
import org.cactoos.scalar.NumberOf; | ||
import org.fusionsoft.database.mapping.dbd.DbdColumnMapping; | ||
import org.fusionsoft.database.mapping.fields.DbdColumnFields; | ||
import org.fusionsoft.lib.yaml.artefacts.TextOfMappingValue; | ||
|
||
public class ColumnOfDbdColumnMapping extends ColumnOfScalar { | ||
|
||
public ColumnOfDbdColumnMapping(final DbdColumnMapping column) { | ||
super( | ||
() -> new SimpleColumn( | ||
new TextOfMappingValue(column, DbdColumnFields.DBNAME), | ||
new NumberOf( | ||
new TextOfMappingValue(column, DbdColumnFields.ORDER) | ||
), | ||
new ValueFormatOfIuType( | ||
new TextOfMappingValue(column, DbdColumnFields.IUTYPE) | ||
) | ||
) | ||
); | ||
} | ||
|
||
} |
Oops, something went wrong.