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
Showing
15 changed files
with
371 additions
and
88 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. | ||
* Author of State. | ||
* | ||
* @author Aliaksei Bialiauski ([email protected]) | ||
* @since 0.0.0 | ||
*/ | ||
public final class Authors implements XpathList { | ||
public final class Author 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 Author(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 Author(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,87 @@ | ||
/* | ||
* 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.Names; | ||
import org.cactoos.Text; | ||
import org.cactoos.bytes.Sha256DigestOf; | ||
import org.cactoos.io.InputOf; | ||
import org.cactoos.text.HexOf; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* SHA256 for State. | ||
* | ||
* @author Aliaksei Bialiauski (0.0.0) | ||
* @since 0.0.0 | ||
*/ | ||
public final class Sha implements Text { | ||
|
||
/** | ||
* State ID. | ||
*/ | ||
private final String id; | ||
/** | ||
* Master file. | ||
*/ | ||
private final String master; | ||
/** | ||
* CMIG directory. | ||
*/ | ||
private final String cmig; | ||
|
||
/** | ||
* Ctor. | ||
* @param id State ID | ||
* @param mst Master file | ||
* @param cmg CMIG directory | ||
*/ | ||
public Sha( | ||
final String id, | ||
final String mst, | ||
final String cmg | ||
) { | ||
this.id = id; | ||
this.master = mst; | ||
this.cmig = cmg; | ||
} | ||
|
||
@Override | ||
public String asString() throws Exception { | ||
final List<String> contents = new StateChanges( | ||
new Names( | ||
this.master, | ||
this.id | ||
), | ||
this.cmig | ||
).value(); | ||
return new HexOf( | ||
new Sha256DigestOf( | ||
new InputOf( | ||
contents.toString() | ||
) | ||
) | ||
).asString(); | ||
} | ||
} |
Oops, something went wrong.
8d1946d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
32-ae85e224
discovered insrc/main/java/io/github/eocqrs/cmig/Master.java
) and submitted as #36. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.8d1946d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
32-b32bc0c2
discovered insrc/main/java/io/github/eocqrs/cmig/State.java
) and submitted as #37. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.