This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
h1alexbel
committed
Aug 11, 2023
1 parent
2dab3be
commit 550a34b
Showing
15 changed files
with
369 additions
and
86 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,9 +29,13 @@ | |
import io.github.eocqrs.cmig.session.InFile; | ||
import org.cactoos.Scalar; | ||
import org.cactoos.io.ResourceOf; | ||
/* | ||
* @todo #32:45m/DEV Master is set of states inside XML document. | ||
*/ | ||
|
||
|
||
/** | ||
* Master files. | ||
* Set of States. | ||
* | ||
* @author Aliaksei Bialiauski ([email protected]) | ||
* @since 0.0.0 | ||
|
@@ -53,7 +57,10 @@ public final class Master implements Scalar<String> { | |
* @param doc XML | ||
* @param cs Cassandra | ||
*/ | ||
public Master(final XML doc, final Cassandra cs) { | ||
public Master( | ||
final XML doc, | ||
final Cassandra cs | ||
) { | ||
this.xml = doc; | ||
this.cassandra = cs; | ||
} | ||
|
@@ -82,7 +89,7 @@ public Master( | |
|
||
@Override | ||
public String value() throws Exception { | ||
new Names(this.xml).value() | ||
new Names(this.xml, "").value() | ||
.forEach(file -> { | ||
try { | ||
new InFile( | ||
|
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 |
---|---|---|
|
@@ -20,54 +20,21 @@ | |
* SOFTWARE. | ||
*/ | ||
|
||
package io.github.eocqrs.cmig.meta; | ||
package io.github.eocqrs.cmig; | ||
|
||
import com.jcabi.xml.XML; | ||
import com.jcabi.xml.XMLDocument; | ||
import org.cactoos.io.ResourceOf; | ||
|
||
import java.util.List; | ||
import org.cactoos.Scalar; | ||
/* | ||
* @todo #32:30m/DEV design State interface | ||
*/ | ||
|
||
/** | ||
* File IDs. | ||
* State. | ||
* | ||
* @author Aliaksei Bialiauski ([email protected]) | ||
* @since 0.0.0 | ||
*/ | ||
public final class Ids implements XpathList { | ||
|
||
/** | ||
* XML. | ||
*/ | ||
private final XML xml; | ||
|
||
/** | ||
* Ctor. | ||
* | ||
* @param doc XML | ||
*/ | ||
public Ids(final XML doc) { | ||
this.xml = doc; | ||
} | ||
|
||
/** | ||
* Ctor. | ||
* | ||
* @param name File name | ||
* @throws Exception if something went wrong | ||
*/ | ||
public Ids(final String name) throws Exception { | ||
this( | ||
new XMLDocument( | ||
new ResourceOf( | ||
name | ||
).stream() | ||
) | ||
); | ||
} | ||
public interface State extends Scalar<String> { | ||
|
||
@Override | ||
public List<String> value() throws Exception { | ||
return this.xml.xpath("/files/file/@id"); | ||
} | ||
String value() throws Exception; | ||
} |
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 |
---|---|---|
|
@@ -24,50 +24,63 @@ | |
|
||
import com.jcabi.xml.XML; | ||
import com.jcabi.xml.XMLDocument; | ||
import org.cactoos.Scalar; | ||
import org.cactoos.io.ResourceOf; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* File authors. | ||
* Authors of State. | ||
* | ||
* @author Aliaksei Bialiauski ([email protected]) | ||
* @since 0.0.0 | ||
*/ | ||
public final class Authors implements XpathList { | ||
public final class Authors implements Scalar<String> { | ||
|
||
/** | ||
* XML. | ||
*/ | ||
private final XML xml; | ||
/** | ||
* State ID. | ||
*/ | ||
private final String id; | ||
|
||
/** | ||
* Ctor. | ||
* | ||
* @param doc XML | ||
* @param id State ID | ||
*/ | ||
public Authors(final XML doc) { | ||
public Authors(final XML doc, final String id) { | ||
this.xml = doc; | ||
this.id = id; | ||
} | ||
|
||
/** | ||
* Ctor. | ||
* | ||
* @param name File name | ||
* @param id State ID | ||
* @throws Exception if something went wrong | ||
*/ | ||
public Authors(final String name) throws Exception { | ||
public Authors(final String name, final String id) | ||
throws Exception { | ||
this( | ||
new XMLDocument( | ||
new ResourceOf( | ||
name | ||
).stream() | ||
) | ||
), | ||
id | ||
); | ||
} | ||
|
||
@Override | ||
public List<String> value() throws Exception { | ||
return this.xml.xpath("/files/file/@author"); | ||
public String value() throws Exception { | ||
return this.xml.xpath( | ||
"/states/changeState[@id='%s']/@author" | ||
.formatted( | ||
this.id | ||
) | ||
).get(0); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
import java.util.List; | ||
|
||
/** | ||
* File names. | ||
* File names of State. | ||
* | ||
* @author Aliaksei Bialiauski ([email protected]) | ||
* @since 0.0.0 | ||
|
@@ -40,34 +40,48 @@ public final class Names implements XpathList { | |
* XML. | ||
*/ | ||
private final XML xml; | ||
/** | ||
* State ID. | ||
*/ | ||
private final String id; | ||
|
||
/** | ||
* Ctor. | ||
* | ||
* @param doc XML | ||
* @param id State ID | ||
*/ | ||
public Names(final XML doc) { | ||
public Names(final XML doc, final String id) { | ||
this.xml = doc; | ||
this.id = id; | ||
} | ||
|
||
/** | ||
* Ctor. | ||
* | ||
* @param name File name | ||
* @param id State ID | ||
* @throws Exception if something went wrong | ||
*/ | ||
public Names(final String name) throws Exception { | ||
public Names(final String name, final String id) | ||
throws Exception { | ||
this( | ||
new XMLDocument( | ||
new ResourceOf( | ||
name | ||
).stream() | ||
) | ||
), | ||
id | ||
); | ||
} | ||
|
||
@Override | ||
public List<String> value() throws Exception { | ||
return this.xml.xpath("/files/file/text()"); | ||
return this.xml.xpath( | ||
"/states/changeState[@id='%s']/files/file/@path" | ||
.formatted( | ||
this.id | ||
) | ||
); | ||
} | ||
} |
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,80 @@ | ||
/* | ||
* Copyright (c) 2023 Aliaksei Bialiauski, EO-CQRS | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.github.eocqrs.cmig.sha; | ||
|
||
import io.github.eocqrs.cmig.meta.XpathList; | ||
import org.cactoos.Scalar; | ||
import org.cactoos.io.ResourceOf; | ||
import org.cactoos.list.ListOf; | ||
import org.cactoos.text.TextOf; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Contents in State. | ||
* | ||
* @author Aliaksei Bialiauski ([email protected]) | ||
* @since 0.0.0 | ||
*/ | ||
public final class Contents implements Scalar<List<String>> { | ||
|
||
/** | ||
* XPATH lists. | ||
*/ | ||
private final XpathList list; | ||
/** | ||
* CMIG directory. | ||
*/ | ||
private final String cmig; | ||
|
||
/** | ||
* Ctor. | ||
* | ||
* @param lst XPATH list | ||
* @param cmg CMIG directory | ||
*/ | ||
public Contents(final XpathList lst, final String cmg) { | ||
this.list = lst; | ||
this.cmig = cmg; | ||
} | ||
|
||
@Override | ||
public List<String> value() throws Exception { | ||
final List<String> contents = new ListOf<>(); | ||
final List<String> files = this.list.value(); | ||
for (final String file : files) { | ||
final String content = | ||
new TextOf( | ||
new ResourceOf( | ||
"%s/%s" | ||
.formatted( | ||
this.cmig, | ||
file | ||
) | ||
) | ||
).asString(); | ||
contents.add(content); | ||
} | ||
return contents; | ||
} | ||
} |
Oops, something went wrong.