index int64 | repo_id string | file_path string | content string |
|---|---|---|---|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeFactory | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeFactory/attributeValueFactory/UriValueFactory.java | package ai.stapi.graph.attribute.attributeFactory.attributeValueFactory;
import ai.stapi.graph.attribute.attributeFactory.exceptions.CannotCreateAttribute;
import ai.stapi.graph.attribute.attributeValue.AttributeValue;
import ai.stapi.graph.attribute.attributeValue.UriAttributeValue;
public class UriValueFactory implements AttributeValueFactory {
@Override
public AttributeValue<?> create(Object value, String attributeName) {
if (!this.isValidValue(value)) {
throw CannotCreateAttribute.becauseProvidedValueCouldNotBeConvertedToProvidedDataType(
attributeName,
UriAttributeValue.SERIALIZATION_TYPE,
value
);
}
return new UriAttributeValue((String) value);
}
@Override
public boolean supportsDataType(String dataType) {
return dataType.equals(UriAttributeValue.SERIALIZATION_TYPE);
}
@Override
public boolean isValidValue(Object value) {
return value instanceof String;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeFactory | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeFactory/attributeValueFactory/UrlValueFactory.java | package ai.stapi.graph.attribute.attributeFactory.attributeValueFactory;
import ai.stapi.graph.attribute.attributeFactory.exceptions.CannotCreateAttribute;
import ai.stapi.graph.attribute.attributeValue.AttributeValue;
import ai.stapi.graph.attribute.attributeValue.UrlAttributeValue;
public class UrlValueFactory implements AttributeValueFactory {
@Override
public AttributeValue<?> create(Object value, String attributeName) {
if (!this.isValidValue(value)) {
throw CannotCreateAttribute.becauseProvidedValueCouldNotBeConvertedToProvidedDataType(
attributeName,
UrlAttributeValue.SERIALIZATION_TYPE,
value
);
}
return new UrlAttributeValue((String) value);
}
@Override
public boolean supportsDataType(String dataType) {
return dataType.equals(UrlAttributeValue.SERIALIZATION_TYPE);
}
@Override
public boolean isValidValue(Object value) {
return value instanceof String;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeFactory | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeFactory/attributeValueFactory/UuidValueFactory.java | package ai.stapi.graph.attribute.attributeFactory.attributeValueFactory;
import ai.stapi.graph.attribute.attributeFactory.exceptions.CannotCreateAttribute;
import ai.stapi.graph.attribute.attributeValue.AttributeValue;
import ai.stapi.graph.attribute.attributeValue.UuidAttributeValue;
public class UuidValueFactory implements AttributeValueFactory {
@Override
public AttributeValue<?> create(Object value, String attributeName) {
if (!this.isValidValue(value)) {
throw CannotCreateAttribute.becauseProvidedValueCouldNotBeConvertedToProvidedDataType(
attributeName,
UuidAttributeValue.SERIALIZATION_TYPE,
value
);
}
return new UuidAttributeValue((String) value);
}
@Override
public boolean supportsDataType(String dataType) {
return dataType.equals(UuidAttributeValue.SERIALIZATION_TYPE);
}
@Override
public boolean isValidValue(Object value) {
return value instanceof String;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeFactory | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeFactory/attributeValueFactory/XhtmlValueFactory.java | package ai.stapi.graph.attribute.attributeFactory.attributeValueFactory;
import ai.stapi.graph.attribute.attributeFactory.exceptions.CannotCreateAttribute;
import ai.stapi.graph.attribute.attributeValue.AttributeValue;
import ai.stapi.graph.attribute.attributeValue.XhtmlAttributeValue;
public class XhtmlValueFactory implements AttributeValueFactory {
@Override
public AttributeValue<?> create(Object value, String attributeName) {
if (!this.isValidValue(value)) {
throw CannotCreateAttribute.becauseProvidedValueCouldNotBeConvertedToProvidedDataType(
attributeName,
XhtmlAttributeValue.SERIALIZATION_TYPE,
value
);
}
return new XhtmlAttributeValue((String) value);
}
@Override
public boolean supportsDataType(String dataType) {
return dataType.equals(XhtmlAttributeValue.SERIALIZATION_TYPE);
}
@Override
public boolean isValidValue(Object value) {
return value instanceof String;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeFactory | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeFactory/exceptions/CannotCreateAttribute.java | package ai.stapi.graph.attribute.attributeFactory.exceptions;
import ai.stapi.graph.attribute.attributeFactory.AttributeFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.AttributeValueFactory;
import java.util.List;
import java.util.stream.Collectors;
public class CannotCreateAttribute extends RuntimeException {
protected CannotCreateAttribute(String becauseMessage) {
super("Cannot create attribute, because " + becauseMessage);
}
public static CannotCreateAttribute becauseProvidedStructureTypeIsNotSupportedByAnyFactory(
String attributeName,
String structureType,
List<Class<? extends AttributeFactory>> foundFactories
) {
return new CannotCreateAttribute(
"provided structure type is not supported by any factory." +
"\nAttribute name: " + attributeName +
"\nStructure type: " + structureType +
"\n" + (
foundFactories.size() == 0 ?
"No supported factories found." :
"Found Factories: " + foundFactories.stream().map(Class::getSimpleName)
.collect(Collectors.joining(", "))
)
);
}
public static CannotCreateAttribute becauseProvidedStructureTypeIsSupportedByMoreThanOneFactory(
String attributeName,
String structureType,
List<Class<? extends AttributeFactory>> foundFactories
) {
return new CannotCreateAttribute(
"provided structure type is supported by more than one factory." +
"\nAttribute name: " + attributeName +
"\nStructure type: " + structureType +
"\n" + "Found Factories: " + foundFactories.stream().map(Class::getSimpleName)
.collect(Collectors.joining(", ")
)
);
}
public static CannotCreateAttribute becauseProvidedDataTypeIsNotSupportedByExactlyOneValueFactory(
String attributeName,
String dataType,
List<Class<? extends AttributeValueFactory>> foundFactories
) {
return new CannotCreateAttribute(
"provided data type is not supported by exactly one factory." +
"\nAttribute name: " + attributeName +
"\nData type: " + dataType +
"\n" + (
foundFactories.size() == 0 ?
"No supported factories found." :
"Found Factories: " + foundFactories.stream().map(Class::getSimpleName)
.collect(Collectors.joining(", "))
)
);
}
public static CannotCreateAttribute becauseLeafAttributeHadNoValues(
String attributeName
) {
return new CannotCreateAttribute(
"there was no provided a value for leaf attribute." +
"\nAttribute name: " + attributeName
);
}
public static CannotCreateAttribute becauseProvidedValueCouldNotBeConvertedToProvidedDataType(
String attributeName,
String dataType,
Object providedValue
) {
return new CannotCreateAttribute(
"because provided value could not be converted to provided data type." +
"\nAttribute name: " + attributeName +
"\nData type: " + dataType +
"\nProvided value class: " + providedValue.getClass().getSimpleName() +
"\nProvided value in string: " + providedValue
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/AbstractAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
import java.util.Objects;
public abstract class AbstractAttributeValue<T> implements AttributeValue<T> {
private final T value;
protected AbstractAttributeValue(T value) {
this.value = value;
}
@Override
public T getValue() {
return value;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AbstractAttributeValue<?> otherAttributeValue)) {
return false;
}
return this.getValue().equals(otherAttributeValue.getValue());
}
@Override
public int hashCode() {
return Objects.hash(this.getValue());
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/AttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
import java.io.Serializable;
public interface AttributeValue<T> extends Serializable, Comparable<AttributeValue<?>> {
T getValue();
String getDataType();
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/Base64BinaryAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class Base64BinaryAttributeValue extends AbstractAttributeValue<String> implements StringLikeAttributeValue<String> {
public static final String SERIALIZATION_TYPE = "base64Binary";
public Base64BinaryAttributeValue(String value) {
super(value.strip());
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
@Override
public String toStringValue() {
return this.getValue();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/BooleanAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
import org.jetbrains.annotations.NotNull;
public class BooleanAttributeValue extends AbstractAttributeValue<Boolean> {
public static final String SERIALIZATION_TYPE = "boolean";
public BooleanAttributeValue(Boolean value) {
super(value);
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
@Override
public int compareTo(@NotNull AttributeValue<?> other) {
if (other instanceof BooleanAttributeValue otherBooleanValue) {
return this.getValue().compareTo(otherBooleanValue.getValue());
} else {
return -1;
}
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/CanonicalAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class CanonicalAttributeValue extends UriAttributeValue {
public static final String SERIALIZATION_TYPE = "canonical";
public CanonicalAttributeValue(String value) {
super(value.strip());
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/CodeAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class CodeAttributeValue extends StringAttributeValue {
public static final String SERIALIZATION_TYPE = "code";
public CodeAttributeValue(String value) {
super(value);
}
@Override
public String getDataType() {
return CodeAttributeValue.SERIALIZATION_TYPE;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/DateAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
import java.time.LocalDate;
public class DateAttributeValue extends AbstractAttributeValue<LocalDate>
implements StringLikeAttributeValue<LocalDate> {
public static final String SERIALIZATION_TYPE = "date";
public DateAttributeValue(LocalDate date) {
super(date);
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
@Override
public String toStringValue() {
return this.getValue().toString();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/DateTimeAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
import java.time.Instant;
public class DateTimeAttributeValue extends AbstractAttributeValue<Instant>
implements StringLikeAttributeValue<Instant> {
public static final String SERIALIZATION_TYPE = "dateTime";
public DateTimeAttributeValue(Instant value) {
super(value);
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
@Override
public String toStringValue() {
return this.getValue().toString();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/DecimalAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class DecimalAttributeValue extends AbstractAttributeValue<Double> implements NumberLikeAttributeValue<Double> {
public static final String SERIALIZATION_TYPE = "decimal";
public DecimalAttributeValue(Double value) {
super(value);
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
@Override
public Double toDoubleValue() {
return this.getValue();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/IdAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class IdAttributeValue extends StringAttributeValue {
public static final String SERIALIZATION_TYPE = "id";
public IdAttributeValue(String value) {
super(value);
}
@Override
public String getDataType() {
return IdAttributeValue.SERIALIZATION_TYPE;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/InstantAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
public class InstantAttributeValue extends AbstractAttributeValue<Instant>
implements StringLikeAttributeValue<Instant> {
public static final String SERIALIZATION_TYPE = "instant";
public InstantAttributeValue(Instant value) {
super(value);
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
@Override
public String toStringValue() {
DateTimeFormatter formatter = DateTimeFormatter.ISO_INSTANT;
return this.getValue().atZone(ZoneOffset.UTC).format(formatter);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/IntegerAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class IntegerAttributeValue extends AbstractAttributeValue<Integer> implements NumberLikeAttributeValue<Integer> {
public static final String SERIALIZATION_TYPE = "integer";
public IntegerAttributeValue(Integer value) {
super(value);
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
@Override
public Double toDoubleValue() {
return this.getValue().doubleValue();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/MarkdownAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class MarkdownAttributeValue extends StringAttributeValue {
public static final String SERIALIZATION_TYPE = "markdown";
public MarkdownAttributeValue(String value) {
super(value);
}
@Override
public String getDataType() {
return MarkdownAttributeValue.SERIALIZATION_TYPE;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/NumberLikeAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
import org.jetbrains.annotations.NotNull;
public interface NumberLikeAttributeValue<T> extends AttributeValue<T> {
Double toDoubleValue();
@Override
default int compareTo(@NotNull AttributeValue<?> other) {
if (other instanceof BooleanAttributeValue) {
return 1;
}
if (other instanceof NumberLikeAttributeValue<?> otherNumberValue) {
return this.toDoubleValue().compareTo(otherNumberValue.toDoubleValue());
}
return -1;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/OidAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class OidAttributeValue extends UriAttributeValue {
public static final String SERIALIZATION_TYPE = "oid";
public OidAttributeValue(String value) {
super(value.strip());
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/PositiveIntegerAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class PositiveIntegerAttributeValue extends IntegerAttributeValue {
public static final String SERIALIZATION_TYPE = "positiveInt";
public PositiveIntegerAttributeValue(Integer value) {
super(value);
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/StringAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class StringAttributeValue extends AbstractAttributeValue<String> implements StringLikeAttributeValue<String> {
public static final String SERIALIZATION_TYPE = "string";
public StringAttributeValue(String value) {
super(value.strip());
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
@Override
public String toStringValue() {
return this.getValue();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/StringLikeAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
import org.jetbrains.annotations.NotNull;
public interface StringLikeAttributeValue<T> extends AttributeValue<T> {
String toStringValue();
@Override
default int compareTo(@NotNull AttributeValue<?> other) {
if (other instanceof StringLikeAttributeValue<?> otherStringValue) {
var originalThisValue = this.toStringValue();
var originalOtherValue = otherStringValue.toStringValue();
var lowercaseDiff = originalThisValue.toLowerCase().compareTo(originalOtherValue.toLowerCase());
if (lowercaseDiff != 0) {
return lowercaseDiff;
}
return originalThisValue.compareTo(originalOtherValue);
} else {
return 1;
}
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/TimeAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
import java.time.LocalTime;
public class TimeAttributeValue extends AbstractAttributeValue<LocalTime>
implements StringLikeAttributeValue<LocalTime> {
public static final String SERIALIZATION_TYPE = "time";
public TimeAttributeValue(LocalTime value) {
super(value);
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
@Override
public String toStringValue() {
return this.getValue().toString();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/UnknownAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class UnknownAttributeValue extends AbstractAttributeValue<Object> implements StringLikeAttributeValue<Object> {
public static final String SERIALIZATION_TYPE = "unknown";
public UnknownAttributeValue(Object value) {
super(value);
}
@Override
public String getDataType() {
return UnknownAttributeValue.SERIALIZATION_TYPE;
}
@Override
public String toStringValue() {
return this.getValue().toString();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/UnsignedIntegerAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class UnsignedIntegerAttributeValue extends IntegerAttributeValue {
public static final String SERIALIZATION_TYPE = "unsignedInt";
public UnsignedIntegerAttributeValue(Integer value) {
super(value);
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/UriAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class UriAttributeValue extends AbstractAttributeValue<String> implements StringLikeAttributeValue<String> {
public static final String SERIALIZATION_TYPE = "uri";
public UriAttributeValue(String value) {
super(value.strip());
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
@Override
public String toStringValue() {
return this.getValue();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/UrlAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class UrlAttributeValue extends UriAttributeValue {
public static final String SERIALIZATION_TYPE = "url";
public UrlAttributeValue(String value) {
super(value.strip());
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/UuidAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class UuidAttributeValue extends UriAttributeValue {
public static final String SERIALIZATION_TYPE = "uuid";
public UuidAttributeValue(String value) {
super(value.strip());
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/attributeValue/XhtmlAttributeValue.java | package ai.stapi.graph.attribute.attributeValue;
public class XhtmlAttributeValue extends AbstractAttributeValue<String> implements StringLikeAttributeValue<String> {
public static final String SERIALIZATION_TYPE = "xhtml";
public XhtmlAttributeValue(String value) {
super(value.strip());
}
@Override
public String getDataType() {
return SERIALIZATION_TYPE;
}
@Override
public String toStringValue() {
return this.getValue();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/exceptions/AttributeNotFoundException.java | package ai.stapi.graph.attribute.exceptions;
import ai.stapi.graph.exceptions.GraphException;
public class AttributeNotFoundException extends GraphException {
public AttributeNotFoundException(String attributeName) {
super(String.format("Attribute \"%s\" not found.", attributeName));
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/attribute/exceptions/CompositeAttributeCannotBeCreated.java | package ai.stapi.graph.attribute.exceptions;
import ai.stapi.graph.exceptions.GraphException;
import java.util.Set;
public class CompositeAttributeCannotBeCreated extends GraphException {
private CompositeAttributeCannotBeCreated(String becauseMessage) {
super("Composite attribute cannot be created, because" + becauseMessage);
}
public static CompositeAttributeCannotBeCreated becauseNoValuesProvided(String providedName) {
return new CompositeAttributeCannotBeCreated(
"no values provided in constructor. " +
"If you want to create one with no values, you have to at least specify Data Type" +
"\nProvided attribute name: " + providedName
);
}
public static CompositeAttributeCannotBeCreated becauseProvidedValuesHasDifferentDataTypes(
String name,
Set<String> uniqueTypes
) {
return new CompositeAttributeCannotBeCreated(
"provided values in constructor are of different Data Types. " +
"\nProvided attribute name: " + name +
"\nFound Value Data Types: " + uniqueTypes
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/configuration/AttributeFactoryConfiguration.java | package ai.stapi.graph.configuration;
import ai.stapi.graph.attribute.attributeFactory.AttributeFactory;
import ai.stapi.graph.attribute.attributeFactory.GenericAttributeFactory;
import ai.stapi.graph.attribute.attributeFactory.LeafAttributeFactory;
import ai.stapi.graph.attribute.attributeFactory.ListAttributeFactory;
import ai.stapi.graph.attribute.attributeFactory.SetAttributeFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.AttributeValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.Base64BinaryValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.BooleanValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.CanonicalValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.CodeValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.DateAttributeValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.DateTimeAttributeValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.DecimalValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.GenericAttributeValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.IdValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.InstantAttributeValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.IntegerValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.MarkdownValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.OidValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.PositiveIntegerValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.StringValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.TimeAttributeValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.UnknownValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.UnsignedIntegerValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.UriValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.UrlValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.UuidValueFactory;
import ai.stapi.graph.attribute.attributeFactory.attributeValueFactory.XhtmlValueFactory;
import java.util.List;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
@AutoConfiguration
public class AttributeFactoryConfiguration {
@Bean
public LeafAttributeFactory leafAttributeFactory(
GenericAttributeValueFactory genericAttributeValueFactory
) {
return new LeafAttributeFactory(genericAttributeValueFactory);
}
@Bean
public ListAttributeFactory listAttributeFactory(
GenericAttributeValueFactory genericAttributeValueFactory
) {
return new ListAttributeFactory(genericAttributeValueFactory);
}
@Bean
public SetAttributeFactory setAttributeFactory(
GenericAttributeValueFactory genericAttributeValueFactory
) {
return new SetAttributeFactory(genericAttributeValueFactory);
}
@Bean
public GenericAttributeFactory genericAttributeFactory(
List<AttributeFactory> attributeFactories
) {
return new GenericAttributeFactory(attributeFactories);
}
@Bean
public Base64BinaryValueFactory base64BinaryValueFactory() {
return new Base64BinaryValueFactory();
}
@Bean
public BooleanValueFactory booleanValueFactory() {
return new BooleanValueFactory();
}
@Bean
public CanonicalValueFactory canonicalValueFactory() {
return new CanonicalValueFactory();
}
@Bean
public CodeValueFactory codeValueFactory() {
return new CodeValueFactory();
}
@Bean
public DateAttributeValueFactory dateAttributeValueFactory() {
return new DateAttributeValueFactory();
}
@Bean
public DateTimeAttributeValueFactory dateTimeAttributeValueFactory() {
return new DateTimeAttributeValueFactory();
}
@Bean
public DecimalValueFactory decimalValueFactory() {
return new DecimalValueFactory();
}
@Bean
public IdValueFactory idValueFactory() {
return new IdValueFactory();
}
@Bean
public InstantAttributeValueFactory instantAttributeValueFactory() {
return new InstantAttributeValueFactory();
}
@Bean
public IntegerValueFactory integerValueFactory() {
return new IntegerValueFactory();
}
@Bean
public MarkdownValueFactory markdownValueFactory() {
return new MarkdownValueFactory();
}
@Bean
public OidValueFactory oidValueFactory() {
return new OidValueFactory();
}
@Bean
public PositiveIntegerValueFactory positiveIntegerValueFactory() {
return new PositiveIntegerValueFactory();
}
@Bean
public StringValueFactory stringValueFactory() {
return new StringValueFactory();
}
@Bean
public TimeAttributeValueFactory timeAttributeValueFactory() {
return new TimeAttributeValueFactory();
}
@Bean
public UnknownValueFactory unknownValueFactory() {
return new UnknownValueFactory();
}
@Bean
public UnsignedIntegerValueFactory unsignedIntegerValueFactory() {
return new UnsignedIntegerValueFactory();
}
@Bean
public UriValueFactory uriValueFactory() {
return new UriValueFactory();
}
@Bean
public UrlValueFactory urlValueFactory() {
return new UrlValueFactory();
}
@Bean
public UuidValueFactory uuidValueFactory() {
return new UuidValueFactory();
}
@Bean
public XhtmlValueFactory xhtmlValueFactory() {
return new XhtmlValueFactory();
}
@Bean
public GenericAttributeValueFactory genericAttributeValueFactory(
List<AttributeValueFactory> attributeValueFactories
) {
return new GenericAttributeValueFactory(attributeValueFactories);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/configuration/GraphRepositoryConfiguration.java | package ai.stapi.graph.configuration;
import ai.stapi.graph.EdgeRepository;
import ai.stapi.graph.NodeRepository;
import ai.stapi.graph.inMemoryGraph.InMemoryGraphRepository;
import ai.stapi.graph.repositorypruner.InMemoryRepositoryPruner;
import ai.stapi.graph.repositorypruner.RepositoryPruner;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
@AutoConfiguration
public class GraphRepositoryConfiguration {
@Bean
@ConditionalOnMissingBean({NodeRepository.class, EdgeRepository.class})
public InMemoryGraphRepository inMemoryGraphRepository() {
return new InMemoryGraphRepository();
}
@Bean
@ConditionalOnMissingBean
public NodeRepository inMemoryNodeRepository(
InMemoryGraphRepository inMemoryGraphRepository
) {
return inMemoryGraphRepository;
}
@Bean
@ConditionalOnMissingBean
public EdgeRepository inMemoryEdgeRepository(
InMemoryGraphRepository inMemoryGraphRepository
) {
return inMemoryGraphRepository;
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(InMemoryGraphRepository.class)
public RepositoryPruner inMemoryRepositoryPruner(
InMemoryGraphRepository inMemoryGraphRepository
) {
return new InMemoryRepositoryPruner(inMemoryGraphRepository);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/configuration | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/configuration/renderer/ApiRendererConfiguration.java | package ai.stapi.graph.configuration.renderer;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.attributes.ApiAttributeVersionsRenderer;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.attributes.ApiAttributesRenderer;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.edge.ApiEdgeRenderer;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.node.ApiCompactNodeRenderer;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.node.ApiNodePrimaryNameFactory;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.node.ApiNodeRenderer;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
@AutoConfiguration
public class ApiRendererConfiguration {
@Bean
public ApiAttributeVersionsRenderer apiAttributeVersionsRenderer() {
return new ApiAttributeVersionsRenderer();
}
@Bean
public ApiAttributesRenderer apiAttributesRenderer(
ApiAttributeVersionsRenderer apiAttributeVersionsRenderer
) {
return new ApiAttributesRenderer(apiAttributeVersionsRenderer);
}
@Bean
public ApiNodePrimaryNameFactory apiNodePrimaryNameFactory() {
return new ApiNodePrimaryNameFactory();
}
@Bean
public ApiCompactNodeRenderer apiCompactNodeRenderer(
ApiAttributesRenderer apiAttributesRenderer,
ApiNodePrimaryNameFactory apiNodePrimaryNameFactory
) {
return new ApiCompactNodeRenderer(apiAttributesRenderer, apiNodePrimaryNameFactory);
}
@Bean
public ApiEdgeRenderer apiEdgeRenderer(
ApiCompactNodeRenderer apiCompactNodeRenderer,
ApiAttributesRenderer apiAttributesRenderer
) {
return new ApiEdgeRenderer(apiCompactNodeRenderer, apiAttributesRenderer);
}
@Bean
public ApiNodeRenderer apiNodeRenderer(
ApiAttributesRenderer apiAttributesRenderer,
ApiEdgeRenderer apiEdgeRenderer,
ApiNodePrimaryNameFactory apiNodePrimaryNameFactory
) {
return new ApiNodeRenderer(apiAttributesRenderer, apiEdgeRenderer, apiNodePrimaryNameFactory);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/configuration | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/configuration/renderer/IdLessTextRendererConfiguration.java | package ai.stapi.graph.configuration.renderer;
import ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.IdLessTextGraphRenderer;
import ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.attribute.TextAttributeContainerRenderer;
import ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.edge.IdLessTextEdgeRenderer;
import ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.node.IdLessTextNodeRenderer;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
@AutoConfiguration
public class IdLessTextRendererConfiguration {
@Bean
public TextAttributeContainerRenderer textAttributeContainerRenderer() {
return new TextAttributeContainerRenderer();
}
@Bean
public IdLessTextNodeRenderer idLessTextNodeRenderer(
TextAttributeContainerRenderer textAttributeContainerRenderer
) {
return new IdLessTextNodeRenderer(textAttributeContainerRenderer);
}
@Bean
public IdLessTextEdgeRenderer idLessTextEdgeRenderer(
TextAttributeContainerRenderer textAttributeContainerRenderer
) {
return new IdLessTextEdgeRenderer(textAttributeContainerRenderer);
}
@Bean
public IdLessTextGraphRenderer idLessTextGraphRenderer(
IdLessTextNodeRenderer idLessTextNodeRenderer,
IdLessTextEdgeRenderer idLessTextEdgeRenderer
) {
return new IdLessTextGraphRenderer(idLessTextNodeRenderer, idLessTextEdgeRenderer);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/configuration | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/configuration/renderer/RendererConfiguration.java | package ai.stapi.graph.configuration.renderer;
import ai.stapi.graph.renderer.model.GenericGraphRenderer;
import ai.stapi.graph.renderer.model.GraphRenderer;
import ai.stapi.graph.renderer.model.nodeRenderer.GenericNodeRenderer;
import ai.stapi.graph.renderer.model.nodeRenderer.NodeRenderer;
import java.util.List;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
@AutoConfiguration
public class RendererConfiguration {
@Bean
public GenericGraphRenderer genericGraphRenderer(
List<GraphRenderer> graphRenderers
) {
return new GenericGraphRenderer(graphRenderers);
}
@Bean
public GenericNodeRenderer genericNodeRenderer(
List<NodeRenderer> nodeRenderers
) {
return new GenericNodeRenderer(nodeRenderers);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/configuration | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/configuration/renderer/ResponseGraphRendererConfiguration.java | package ai.stapi.graph.configuration.renderer;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.ResponseGraphRenderer;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.attributes.ResponseAttributeVersionsRenderer;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.attributes.ResponseAttributesRenderer;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.edge.ResponseEdgeRenderer;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.node.ResponseNodeRenderer;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
@AutoConfiguration
public class ResponseGraphRendererConfiguration {
@Bean
public ResponseAttributeVersionsRenderer responseAttributeVersionsRenderer() {
return new ResponseAttributeVersionsRenderer();
}
@Bean
public ResponseAttributesRenderer responseAttributesRenderer(
ResponseAttributeVersionsRenderer responseAttributeVersionsRenderer
) {
return new ResponseAttributesRenderer(responseAttributeVersionsRenderer);
}
@Bean
public ResponseNodeRenderer responseNodeRenderer(
ResponseAttributesRenderer responseAttributesRenderer
) {
return new ResponseNodeRenderer(responseAttributesRenderer);
}
@Bean
public ResponseEdgeRenderer responseEdgeRenderer(
ResponseAttributesRenderer responseAttributesRenderer
) {
return new ResponseEdgeRenderer(responseAttributesRenderer);
}
@Bean
public ResponseGraphRenderer responseGraphRenderer(
ResponseNodeRenderer responseNodeRenderer,
ResponseEdgeRenderer responseEdgeRenderer
) {
return new ResponseGraphRenderer(responseNodeRenderer, responseEdgeRenderer);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/configuration | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/configuration/renderer/TextRendererConfiguration.java | package ai.stapi.graph.configuration.renderer;
import ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.edge.IdLessTextEdgeRenderer;
import ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.node.IdLessTextNodeRenderer;
import ai.stapi.graph.renderer.infrastructure.textRenderer.edge.TextEdgeRenderer;
import ai.stapi.graph.renderer.infrastructure.textRenderer.node.TextNodeRenderer;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
@AutoConfiguration
@AutoConfigureAfter(IdLessTextRendererConfiguration.class)
public class TextRendererConfiguration {
@Bean
public TextNodeRenderer textNodeRenderer(
IdLessTextNodeRenderer idLessTextNodeRenderer
) {
return new TextNodeRenderer(idLessTextNodeRenderer);
}
@Bean
public TextEdgeRenderer textEdgeRenderer(
IdLessTextEdgeRenderer idLessTextEdgeRenderer
) {
return new TextEdgeRenderer(idLessTextEdgeRenderer);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/exceptions/EdgeNotFound.java | package ai.stapi.graph.exceptions;
import ai.stapi.identity.UniqueIdentifier;
public class EdgeNotFound extends GraphException {
public EdgeNotFound(UniqueIdentifier edgeId, String edgeType) {
super(
String.format(
"Edge with id \"%s\" of type \"%s\" not found.",
edgeId.toString(),
edgeType
)
);
}
public EdgeNotFound(UniqueIdentifier edgeId) {
super(
String.format(
"Edge with id \"%s\" not found in any collection.",
edgeId.toString()
)
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/exceptions/EdgeWithSameIdAndTypeAlreadyExists.java | package ai.stapi.graph.exceptions;
public class EdgeWithSameIdAndTypeAlreadyExists extends GraphException {
public EdgeWithSameIdAndTypeAlreadyExists(String edgeId, String edgeType) {
super(
"Edge can not be saved, because edge with same id [" + edgeId
+ "] and type [" + edgeType + "] already exists."
+ "You can use replace instead."
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/exceptions/GraphElementNotFound.java | package ai.stapi.graph.exceptions;
import ai.stapi.identity.UniqueIdentifier;
public class GraphElementNotFound extends GraphException {
public GraphElementNotFound(UniqueIdentifier graphElementId) {
super(
String.format(
"Graph element with id \"%s\" not found.",
graphElementId
)
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/exceptions/GraphException.java | package ai.stapi.graph.exceptions;
import ai.stapi.graph.inMemoryGraph.InMemoryGraphRepository;
public class GraphException extends RuntimeException {
protected transient InMemoryGraphRepository graph;
public GraphException(String message) {
super(message);
this.graph = new InMemoryGraphRepository();
}
public GraphException(String message, Throwable t) {
super(message, t);
this.graph = new InMemoryGraphRepository();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/exceptions/MoreThanOneNodeFoundWithGivenAttributeException.java | package ai.stapi.graph.exceptions;
public class MoreThanOneNodeFoundWithGivenAttributeException extends GraphException {
public MoreThanOneNodeFoundWithGivenAttributeException(String name, Object value) {
super(
String.format(
"More than one node found with \"%s\" attribute name and value: \"%s\"",
name,
value
)
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/exceptions/MoreThanOneNodeOfTypeFoundException.java | package ai.stapi.graph.exceptions;
public class MoreThanOneNodeOfTypeFoundException extends GraphException {
public MoreThanOneNodeOfTypeFoundException(String nodeType) {
super(String.format("More than one node of type: \"%s\" found, but expected exactly one.",
nodeType));
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/exceptions/NodeNotFound.java | package ai.stapi.graph.exceptions;
import ai.stapi.identity.UniqueIdentifier;
public class NodeNotFound extends GraphException {
public NodeNotFound(UniqueIdentifier nodeId, String nodeType) {
super(
String.format(
"Node with id \"%s\" of type \"%s\" not found.",
nodeId.toString(),
nodeType
)
);
}
public NodeNotFound(UniqueIdentifier nodeId) {
super(
String.format(
"Node with id \"%s\" not found in any collection.",
nodeId.toString()
)
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/exceptions/NodeOfTypeNotFoundException.java | package ai.stapi.graph.exceptions;
public class NodeOfTypeNotFoundException extends GraphException {
public NodeOfTypeNotFoundException(String nodeType) {
super(String.format("Node of type: \"%s\" not found.", nodeType));
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/exceptions/NodeWithSameIdAndTypeAlreadyExists.java | package ai.stapi.graph.exceptions;
import ai.stapi.identity.UniqueIdentifier;
public class NodeWithSameIdAndTypeAlreadyExists extends GraphException {
public NodeWithSameIdAndTypeAlreadyExists(UniqueIdentifier uuid, String type) {
super(
"Node can not be saved, because node with same id and type already exists." +
"You can use replace instead." +
"\nUUID: " + uuid.toString() +
"\nNode Type: " + type
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/exceptions/OneOrBothNodesOnEdgeDoesNotExist.java | package ai.stapi.graph.exceptions;
import ai.stapi.graph.graphelements.Edge;
public class OneOrBothNodesOnEdgeDoesNotExist extends GraphException {
public OneOrBothNodesOnEdgeDoesNotExist(Edge edge) {
super(
String.format(
"One or both nodes on edge you are trying to save does not exist. Create them first. Details: \n" +
"Node From: id: %s ; type: %s \n" +
"Node To: id: %s ; type: %s \n",
edge.getNodeFromId().getId(),
edge.getNodeFromType(),
edge.getNodeToId().getId(),
edge.getNodeToType()
)
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/exceptions/UnableToReplaceNode.java | package ai.stapi.graph.exceptions;
public class UnableToReplaceNode extends GraphException {
public UnableToReplaceNode(String message) {
super(message);
}
public static UnableToReplaceNode becauseNotAllowedToReplaceNodeForAnotherType(
String currentNodeType,
Object replacingNodeType
) {
return new UnableToReplaceNode(
"because it is not allowed to replace node for another type." +
"\nCurrent node type: " + currentNodeType +
"\nReplacing node type: " + replacingNodeType
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/graphElementForRemoval/EdgeForRemoval.java | package ai.stapi.graph.graphElementForRemoval;
import ai.stapi.graph.traversableGraphElements.TraversableEdge;
import ai.stapi.identity.UniqueIdentifier;
public class EdgeForRemoval implements GraphElementForRemoval {
public static final String ELEMENT_BASE_TYPE = "EDGE";
private final UniqueIdentifier edgeId;
private final String edgeType;
public EdgeForRemoval(UniqueIdentifier edgeId, String edgeType) {
this.edgeId = edgeId;
this.edgeType = edgeType;
}
public EdgeForRemoval(TraversableEdge edge) {
this.edgeId = edge.getId();
this.edgeType = edge.getType();
}
@Override
public UniqueIdentifier getGraphElementId() {
return this.edgeId;
}
@Override
public String getGraphElementType() {
return this.edgeType;
}
@Override
public String getGraphElementBaseType() {
return ELEMENT_BASE_TYPE;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/graphElementForRemoval/GraphElementForRemoval.java | package ai.stapi.graph.graphElementForRemoval;
import ai.stapi.identity.UniqueIdentifier;
public interface GraphElementForRemoval {
UniqueIdentifier getGraphElementId();
String getGraphElementType();
String getGraphElementBaseType();
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/graphElementForRemoval/NodeForRemoval.java | package ai.stapi.graph.graphElementForRemoval;
import ai.stapi.graph.graphelements.Node;
import ai.stapi.graph.traversableGraphElements.TraversableNode;
import ai.stapi.identity.UniqueIdentifier;
public class NodeForRemoval implements GraphElementForRemoval {
public static final String ELEMENT_BASE_TYPE = "NODE";
private final UniqueIdentifier nodeId;
private final String nodeType;
public NodeForRemoval(UniqueIdentifier nodeId, String nodeType) {
this.nodeId = nodeId;
this.nodeType = nodeType;
}
public NodeForRemoval(TraversableNode node) {
this.nodeId = node.getId();
this.nodeType = node.getType();
}
public NodeForRemoval(Node node) {
this.nodeId = node.getId();
this.nodeType = node.getType();
}
@Override
public UniqueIdentifier getGraphElementId() {
return this.nodeId;
}
@Override
public String getGraphElementType() {
return this.nodeType;
}
@Override
public String getGraphElementBaseType() {
return ELEMENT_BASE_TYPE;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/graphelements/AbstractGraphElement.java | package ai.stapi.graph.graphelements;
import ai.stapi.graph.attribute.AbstractAttributeContainer;
import ai.stapi.graph.attribute.Attribute;
import ai.stapi.graph.versionedAttributes.VersionedAttributeGroup;
import ai.stapi.identity.UniqueIdentifier;
public abstract class AbstractGraphElement extends AbstractAttributeContainer
implements GraphElement {
protected final UniqueIdentifier id;
protected final String type;
protected AbstractGraphElement(UniqueIdentifier id, String type) {
this.id = id;
this.type = type;
}
protected AbstractGraphElement(
UniqueIdentifier id,
String type,
VersionedAttributeGroup versionedAttributes
) {
super(versionedAttributes);
this.id = id;
this.type = type;
}
protected AbstractGraphElement(UniqueIdentifier id, String type, Attribute<?>... attributes) {
super(attributes);
this.id = id;
this.type = type;
}
@Override
public String getType() {
return this.type;
}
@Override
public UniqueIdentifier getId() {
return this.id;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/graphelements/Edge.java | package ai.stapi.graph.graphelements;
import ai.stapi.graph.AttributeContainer;
import ai.stapi.graph.NodeIdAndType;
import ai.stapi.graph.attribute.Attribute;
import ai.stapi.graph.inMemoryGraph.exceptions.GraphEdgesCannotBeMerged;
import ai.stapi.graph.traversableGraphElements.TraversableEdge;
import ai.stapi.graph.versionedAttributes.VersionedAttributeGroup;
import ai.stapi.identity.UniqueIdentifier;
import ai.stapi.identity.UniversallyUniqueIdentifier;
import java.util.Objects;
public class Edge extends AbstractGraphElement {
private final UniqueIdentifier nodeFromId;
private final UniqueIdentifier nodeToId;
private final String nodeFromType;
private final String nodeToType;
public Edge(
UniqueIdentifier id,
String type,
VersionedAttributeGroup versionedAttributes,
NodeIdAndType nodeFromIdAndType,
NodeIdAndType nodeToIdAndType
) {
super(id, type, versionedAttributes);
this.nodeFromId = nodeFromIdAndType.getId();
this.nodeToId = nodeToIdAndType.getId();
this.nodeFromType = nodeFromIdAndType.getType();
this.nodeToType = nodeToIdAndType.getType();
}
public Edge(
UniqueIdentifier edgeId,
Node nodeFrom,
String edgeType,
Node nodeTo
) {
super(edgeId, edgeType);
this.nodeFromId = nodeFrom.getId();
this.nodeFromType = nodeFrom.getType();
this.nodeToId = nodeTo.getId();
this.nodeToType = nodeTo.getType();
}
public Edge(
UniqueIdentifier edgeId,
String edgeType,
Node nodeFrom,
Node nodeTo,
VersionedAttributeGroup attributeGroup
) {
super(edgeId, edgeType, attributeGroup);
this.nodeFromId = nodeFrom.getId();
this.nodeFromType = nodeFrom.getType();
this.nodeToId = nodeTo.getId();
this.nodeToType = nodeTo.getType();
}
public Edge(
UniqueIdentifier edgeId,
Node nodeFrom,
String edgeType,
Node nodeTo,
Attribute<?>... attributes
) {
super(edgeId, edgeType, attributes);
this.nodeFromId = nodeFrom.getId();
this.nodeFromType = nodeFrom.getType();
this.nodeToId = nodeTo.getId();
this.nodeToType = nodeTo.getType();
}
public Edge(TraversableEdge traversableEdge) {
this(
traversableEdge.getId(),
traversableEdge.getType(),
new Node(traversableEdge.getNodeFrom()),
new Node(traversableEdge.getNodeTo()),
traversableEdge.getVersionedAttributes()
);
}
public Edge(Node nodeFrom, String edgeType, Node nodeTo) {
this(
UniversallyUniqueIdentifier.randomUUID(),
nodeFrom,
edgeType,
nodeTo
);
}
public Edge(
Node nodeFrom,
String edgeType,
Node nodeTo,
VersionedAttributeGroup attributeGroup
) {
this(UniversallyUniqueIdentifier.randomUUID(), edgeType, nodeFrom, nodeTo,
attributeGroup);
}
public Edge(
Node nodeFrom,
String edgeType,
Node nodeTo,
Attribute<?>... attributes
) {
this(UniversallyUniqueIdentifier.randomUUID(), nodeFrom, edgeType, nodeTo,
attributes);
}
public Edge(
UniqueIdentifier edgeId,
String edgeType,
UniqueIdentifier nodeFromId,
UniqueIdentifier nodeToId,
String nodeFromType,
String nodeToType,
VersionedAttributeGroup versionedAttributes
) {
super(edgeId, edgeType, versionedAttributes);
this.nodeFromId = nodeFromId;
this.nodeToId = nodeToId;
this.nodeFromType = nodeFromType;
this.nodeToType = nodeToType;
}
public UniqueIdentifier getNodeFromId() {
return this.nodeFromId;
}
public UniqueIdentifier getNodeToId() {
return this.nodeToId;
}
public String getNodeFromType() {
return this.nodeFromType;
}
public String getNodeToType() {
return this.nodeToType;
}
@Override
protected AttributeContainer withNewAttributes(VersionedAttributeGroup newAttributes) {
return new Edge(
this.getId(),
this.getType(),
this.getNodeFromId(),
this.getNodeToId(),
this.getNodeFromType(),
this.getNodeToType(),
newAttributes
);
}
@Override
public Edge add(Attribute<?> attribute) {
return (Edge) super.add(attribute);
}
@Override
protected int getHashCodeWithoutAttributes() {
return Objects.hash(this.getId()) + this.getIdlessHashCodeWithoutAttributes();
}
@Override
protected int getIdlessHashCodeWithoutAttributes() {
return Objects.hash(this.getType());
}
public NodeIdAndType getNodeFromIdAndType() {
return new NodeIdAndType(this.nodeFromId, this.nodeFromType);
}
public NodeIdAndType getNodeToIdAndType() {
return new NodeIdAndType(this.nodeToId, this.nodeToType);
}
public Edge getCopy() {
return this;
}
public Edge mergeOverwrite(Edge otherEdge) {
if (!this.getId().equals(otherEdge.getId())) {
throw GraphEdgesCannotBeMerged.becauseTheyHaveDifferentIds();
}
if (!this.getType().equals(otherEdge.getType())) {
throw GraphEdgesCannotBeMerged.becauseTheyHaveDifferentTypes();
}
if (!(this.getNodeFromId().equals(otherEdge.getNodeFromId()))
|| !(this.getNodeToId().equals(otherEdge.getNodeToId()))) {
throw GraphEdgesCannotBeMerged.becauseTheyHaveDifferentNodeIds();
}
return (Edge) this.mergeAttributesWithAttributesOf(otherEdge);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/graphelements/GraphElement.java | package ai.stapi.graph.graphelements;
import ai.stapi.identity.UniqueIdentifier;
import java.io.Serializable;
public interface GraphElement extends Serializable {
String getType();
UniqueIdentifier getId();
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/graphelements/Node.java | package ai.stapi.graph.graphelements;
import ai.stapi.graph.AttributeContainer;
import ai.stapi.graph.attribute.Attribute;
import ai.stapi.graph.inMemoryGraph.exceptions.GraphNodesCannotBeMerged;
import ai.stapi.graph.traversableGraphElements.TraversableNode;
import ai.stapi.graph.versionedAttributes.VersionedAttributeGroup;
import ai.stapi.identity.UniqueIdentifier;
import ai.stapi.identity.UniversallyUniqueIdentifier;
import java.util.Objects;
public class Node extends AbstractGraphElement {
public Node(UniqueIdentifier id, String nodeType) {
super(id, nodeType);
}
public Node(
UniqueIdentifier id,
String type,
VersionedAttributeGroup versionedAttributes
) {
super(id, type, versionedAttributes);
}
public Node(UniqueIdentifier id, String nodeType, Attribute<?>... attributes) {
super(id, nodeType, attributes);
}
public Node(String nodeType) {
this(UniversallyUniqueIdentifier.randomUUID(), nodeType);
}
public Node(TraversableNode node) {
this(node.getId(), node.getType(), node.getVersionedAttributes());
}
public Node(Node node) {
this(node.getId(), node.getType(), node.getVersionedAttributes());
}
public Node(String nodeType, Attribute<?>... attributes) {
this(UniversallyUniqueIdentifier.randomUUID(), nodeType, attributes);
}
@Override
protected AttributeContainer withNewAttributes(VersionedAttributeGroup newAttributes) {
return new Node(
this.getId(),
this.getType(),
newAttributes
);
}
@Override
protected int getHashCodeWithoutAttributes() {
return Objects.hash(this.getId()) + this.getIdlessHashCodeWithoutAttributes();
}
@Override
protected int getIdlessHashCodeWithoutAttributes() {
return Objects.hash(this.getType());
}
@Override
public Node add(Attribute<?> attribute) {
return (Node) super.add(attribute);
}
public Node mergeOverwrite(Node otherNode) {
if (!this.getId().equals(otherNode.getId())) {
throw GraphNodesCannotBeMerged.becauseTheyHaveDifferentIds();
}
if (!this.getType().equals(otherNode.getType())) {
throw GraphNodesCannotBeMerged.becauseTheyHaveDifferentTypes(
this.getType(),
otherNode.getType()
);
}
return (Node) this.mergeAttributesWithAttributesOf(otherNode);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph/DeduplicateOptions.java | package ai.stapi.graph.inMemoryGraph;
public enum DeduplicateOptions {
SAME_EDGE_TYPES_BETWEEN_SAME_NODES
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph/EdgeBuilder.java | package ai.stapi.graph.inMemoryGraph;
import ai.stapi.graph.graphelements.Edge;
import ai.stapi.graph.versionedAttributes.ImmutableVersionedAttributeGroup;
import ai.stapi.graph.versionedAttributes.VersionedAttributeGroup;
import ai.stapi.identity.UniqueIdentifier;
import ai.stapi.identity.UniversallyUniqueIdentifier;
public class EdgeBuilder {
private UniqueIdentifier edgeId = UniversallyUniqueIdentifier.randomUUID();
private String edgeType;
private UniqueIdentifier nodeFromId;
private String nodeFromType;
private UniqueIdentifier nodeToId;
private String nodeToType;
private VersionedAttributeGroup versionedAttributes;
public static EdgeBuilder withAny() {
return new EdgeBuilder()
.setEdgeId(UniversallyUniqueIdentifier.randomUUID())
.setEdgeType("any_edge_type")
.setNodeFromId(UniversallyUniqueIdentifier.randomUUID())
.setNodeToId(UniversallyUniqueIdentifier.randomUUID())
.setNodeFromType("any_node_from_type")
.setNodeToType("any_node_to_type")
.setVersionedAttributes(new ImmutableVersionedAttributeGroup());
}
public EdgeBuilder setNodeFromId(UniqueIdentifier nodeFromId) {
this.nodeFromId = nodeFromId;
return this;
}
public EdgeBuilder setEdgeType(String edgeType) {
this.edgeType = edgeType;
return this;
}
public EdgeBuilder setNodeToId(UniqueIdentifier nodeToId) {
this.nodeToId = nodeToId;
return this;
}
public EdgeBuilder setNodeFromType(String nodeFromType) {
this.nodeFromType = nodeFromType;
return this;
}
public EdgeBuilder setNodeToType(String nodeToType) {
this.nodeToType = nodeToType;
return this;
}
public EdgeBuilder setEdgeId(UniqueIdentifier edgeId) {
this.edgeId = edgeId;
return this;
}
public EdgeBuilder setVersionedAttributes(VersionedAttributeGroup versionedAttributes) {
this.versionedAttributes = versionedAttributes;
return this;
}
public Edge create() {
return new Edge(
edgeId,
edgeType,
nodeFromId,
nodeToId,
nodeFromType,
nodeToType,
this.versionedAttributes
);
}
} |
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph/InMemoryGraphRepository.java | package ai.stapi.graph.inMemoryGraph;
import ai.stapi.graph.AttributeContainer;
import ai.stapi.graph.EdgeRepository;
import ai.stapi.graph.EdgeTypeInfo;
import ai.stapi.graph.Graph;
import ai.stapi.graph.NodeIdAndType;
import ai.stapi.graph.NodeInfo;
import ai.stapi.graph.NodeRepository;
import ai.stapi.graph.NodeTypeInfo;
import ai.stapi.graph.RepositoryEdgeLoader;
import ai.stapi.graph.RepositoryNodeLoader;
import ai.stapi.graph.exceptions.GraphElementNotFound;
import ai.stapi.graph.graphElementForRemoval.EdgeForRemoval;
import ai.stapi.graph.graphElementForRemoval.GraphElementForRemoval;
import ai.stapi.graph.graphElementForRemoval.NodeForRemoval;
import ai.stapi.graph.graphelements.Edge;
import ai.stapi.graph.graphelements.Node;
import ai.stapi.graph.traversableGraphElements.TraversableEdge;
import ai.stapi.graph.traversableGraphElements.TraversableGraphElement;
import ai.stapi.graph.traversableGraphElements.TraversableNode;
import ai.stapi.identity.UniqueIdentifier;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
import org.jetbrains.annotations.TestOnly;
public class InMemoryGraphRepository implements NodeRepository, EdgeRepository {
private Graph graph;
private ConcurrentHashMap<UniqueIdentifier, ConcurrentSkipListSet<TraversableEdge>> nodesEdgesMap;
public InMemoryGraphRepository() {
this(new Graph());
}
public InMemoryGraphRepository(Graph graph) {
this.graph = graph;
this.recalculateNodesEdgesMap();
}
public InMemoryGraphRepository(AttributeContainer... graphElements) {
this(new Graph(graphElements));
}
@Override
public void save(Edge edge) {
this.graph = this.graph.with(edge);
NodeEdgesMapOperation.upsertEdge(this.nodesEdgesMap, this.toTraversableEdge(edge));
}
@Override
public void removeEdge(UniqueIdentifier edgeId, String edgeType) {
var edgeToRemove = this.graph.getEdge(edgeId, edgeType);
this.graph = this.graph.removeEdge(
new EdgeForRemoval(edgeId, edgeType)
);
NodeEdgesMapOperation.removeEdge(this.nodesEdgesMap, edgeToRemove);
}
@Override
public void replace(Edge edge) {
var edgeToRemove = this.graph.getEdge(edge.getId(), edge.getType());
var oldGraph = this.graph;
this.graph = oldGraph.replace(edge);
var newEdge = this.loadEdge(edge.getId(), edge.getType());
NodeEdgesMapOperation.removeEdge(this.nodesEdgesMap, edgeToRemove);
NodeEdgesMapOperation.upsertEdge(this.nodesEdgesMap, newEdge);
}
@Override
public void removeEdge(EdgeForRemoval edgeForRemoval) {
this.graph = this.graph.removeEdge(edgeForRemoval);
}
@Override
public void replace(Node node) {
this.graph = this.graph.replace(node);
}
@Override
public void removeNode(UniqueIdentifier id, String nodeType) {
this.graph = this.graph.removeNode(id, nodeType);
}
@Override
public void removeNode(NodeForRemoval nodeForRemoval) {
this.graph = this.graph.removeNode(nodeForRemoval);
}
public void removeAllElements() {
this.graph = new Graph();
}
private TraversableNode toTraversableNode(Node node) {
return new TraversableNode(
node.getId(),
node.getType(),
node.getVersionedAttributes(),
new RepositoryEdgeLoader(this)
);
}
private TraversableEdge toTraversableEdge(Edge edge) {
if (edge == null) {
return null;
}
return new TraversableEdge(
edge.getId(),
this.loadNode(edge.getNodeFromId(), edge.getNodeFromType()),
edge.getType(),
this.loadNode(edge.getNodeToId(), edge.getNodeToType()),
edge.getVersionedAttributes(),
new RepositoryNodeLoader(this)
);
}
@Override
public TraversableEdge loadEdge(UniqueIdentifier id, String type) {
return this.toTraversableEdge(
this.graph.getEdge(id, type)
);
}
@Override
public boolean edgeExists(UniqueIdentifier id, String type) {
return this.graph.edgeExists(id, type);
}
@Override
public List<EdgeTypeInfo> getEdgeTypeInfos() {
return this.graph.getEdgeTypeInfos();
}
public Set<TraversableEdge> findInAndOutEdgesForNode(
UniqueIdentifier nodeId,
String nodeType
) {
return NodeEdgesMapOperation.getNodeEdges(this.nodesEdgesMap, nodeId, nodeType);
}
@Override
public TraversableEdge findEdgeByTypeAndNodes(
String edgeType,
NodeIdAndType nodeFrom,
NodeIdAndType nodeTo
) {
return this.toTraversableEdge(
this.graph.findEdgeByTypeAndNodes(
edgeType,
nodeFrom,
nodeTo
)
);
}
@Override
public void save(Node node) {
this.graph = this.graph.with(node);
}
@Override
public TraversableNode loadNode(UniqueIdentifier uniqueIdentifier, String nodeType) {
return this.toTraversableNode(
this.graph.getNode(uniqueIdentifier, nodeType)
);
}
public TraversableGraphElement loadGraphElement(UniqueIdentifier uuid, String elementType) {
if (this.nodeExists(uuid, elementType)) {
return this.loadNode(uuid, elementType);
}
if (this.edgeExists(uuid, elementType)) {
return this.loadEdge(uuid, elementType);
}
throw new GraphElementNotFound(uuid);
}
@Override
public boolean nodeExists(UniqueIdentifier id, String nodeType) {
return this.graph.nodeExists(id, nodeType);
}
@Override
public List<NodeTypeInfo> getNodeTypeInfos() {
return this.graph.getNodeTypeInfos();
}
@Override
public List<NodeInfo> getNodeInfosBy(String nodeType) {
return this.graph.getNodeInfosBy(nodeType);
}
public List<TraversableNode> loadAllNodes(String nodeType) {
return this.graph.getAllNodes().stream().filter(
node -> node.getType().equals(nodeType)
).map(this::toTraversableNode).toList();
}
public List<TraversableNode> loadAllNodes() {
return this.graph.getAllNodes().stream()
.map(this::toTraversableNode).toList();
}
public List<TraversableEdge> loadAllEdges() {
List<Edge> allEdges = this.graph.getAllEdges();
return allEdges.stream()
.map(this::toTraversableEdge).toList();
}
public List<TraversableEdge> loadAllEdges(String edgeType) {
return this.graph.getAllEdges().stream()
.filter(edge -> edge.getType().equals(edgeType))
.map(this::toTraversableEdge).toList();
}
public void merge(Graph otherGraph) {
this.graph = this.graph.merge(otherGraph);
this.recalculateNodesEdgesMap();
}
public void merge(InMemoryGraphRepository otherGraph) {
this.merge(otherGraph.getGraph());
}
public void removeGraphElements(GraphElementForRemoval... graphElementsForRemoval) {
this.graph = this.graph.removeGraphElements(graphElementsForRemoval);
this.recalculateNodesEdgesMap();
}
public Graph getGraph() {
return graph;
}
public void merge(Graph otherGraph, DeduplicateOptions options) {
this.graph = this.graph.merge(otherGraph, options);
this.recalculateNodesEdgesMap();
}
@TestOnly
public void prune() {
this.graph = new Graph();
}
private void recalculateNodesEdgesMap() {
this.nodesEdgesMap = new ConcurrentHashMap<>();
for (var edge : this.loadAllEdges()) {
NodeEdgesMapOperation.upsertEdge(this.nodesEdgesMap, edge);
}
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph/NodeEdgesMapOperation.java | package ai.stapi.graph.inMemoryGraph;
import ai.stapi.graph.graphelements.Edge;
import ai.stapi.graph.traversableGraphElements.TraversableEdge;
import ai.stapi.identity.UniqueIdentifier;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
public class NodeEdgesMapOperation {
public static ConcurrentHashMap<UniqueIdentifier, ConcurrentSkipListSet<TraversableEdge>> create(
InMemoryGraphRepository graph
) {
ConcurrentHashMap<UniqueIdentifier, ConcurrentSkipListSet<TraversableEdge>> map =
new ConcurrentHashMap<>();
for (var edge : graph.loadAllEdges()) {
map = NodeEdgesMapOperation.addEdgeToNodeInRelationMap(map, edge, edge.getNodeFromId());
map = NodeEdgesMapOperation.addEdgeToNodeInRelationMap(map, edge, edge.getNodeToId());
}
return map;
}
public static ConcurrentSkipListSet<TraversableEdge> getNodeEdges(
ConcurrentHashMap<UniqueIdentifier, ConcurrentSkipListSet<TraversableEdge>> map,
UniqueIdentifier nodeId,
String nodeType
) {
if (map.containsKey(nodeId)) {
return map.get(nodeId);
}
return new ConcurrentSkipListSet();
}
public static ConcurrentHashMap<UniqueIdentifier, ConcurrentSkipListSet<TraversableEdge>> upsertEdge(
ConcurrentHashMap<UniqueIdentifier, ConcurrentSkipListSet<TraversableEdge>> map,
TraversableEdge edge
) {
map = NodeEdgesMapOperation.addEdgeToNodeInRelationMap(map, edge, edge.getNodeFromId());
map = NodeEdgesMapOperation.addEdgeToNodeInRelationMap(map, edge, edge.getNodeToId());
return map;
}
public static ConcurrentHashMap<UniqueIdentifier, ConcurrentSkipListSet<TraversableEdge>> removeEdge(
ConcurrentHashMap<UniqueIdentifier, ConcurrentSkipListSet<TraversableEdge>> map,
Edge edge
) {
map = NodeEdgesMapOperation.removeEdgeFromNodeInRelationMap(map, edge.getId(),
edge.getNodeFromId());
map = NodeEdgesMapOperation.removeEdgeFromNodeInRelationMap(map, edge.getId(),
edge.getNodeToId());
return map;
}
private static ConcurrentHashMap<UniqueIdentifier, ConcurrentSkipListSet<TraversableEdge>> addEdgeToNodeInRelationMap(
ConcurrentHashMap<UniqueIdentifier, ConcurrentSkipListSet<TraversableEdge>> originalMap,
TraversableEdge traversableEdge,
UniqueIdentifier nodeId
) {
ConcurrentSkipListSet<TraversableEdge> set = new ConcurrentSkipListSet<>();
if (originalMap.containsKey(nodeId)) {
set = originalMap.get(nodeId);
} else {
originalMap.put(nodeId, set);
}
set.add(traversableEdge);
return originalMap;
}
private static ConcurrentHashMap<UniqueIdentifier, ConcurrentSkipListSet<TraversableEdge>> removeEdgeFromNodeInRelationMap(
ConcurrentHashMap<UniqueIdentifier, ConcurrentSkipListSet<TraversableEdge>> originalMap,
UniqueIdentifier edgeId,
UniqueIdentifier nodeId
) {
if (!originalMap.containsKey(nodeId)) {
throw new RuntimeException(
"Trying to remove edge %s from nodeEdge map, but node %s is not present");
}
originalMap.get(nodeId).removeIf(
traversableEdge -> edgeId.equals(traversableEdge.getId())
);
return originalMap;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph/exceptions/CannotCreateGraphWithOtherThanGraphElements.java | package ai.stapi.graph.inMemoryGraph.exceptions;
import ai.stapi.graph.exceptions.GraphException;
public class CannotCreateGraphWithOtherThanGraphElements extends GraphException {
public CannotCreateGraphWithOtherThanGraphElements() {
super(
String.format(
"Cannot create Graph with other than Node or Edge."
)
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph/exceptions/GraphEdgesCannotBeMerged.java | package ai.stapi.graph.inMemoryGraph.exceptions;
import ai.stapi.graph.exceptions.GraphException;
import ai.stapi.identity.UniqueIdentifier;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
public class GraphEdgesCannotBeMerged extends GraphException {
protected GraphEdgesCannotBeMerged(String message) {
super("Graph edges could not be merged, " + message);
}
public static GraphEdgesCannotBeMerged becauseTheyHaveDifferentTypes() {
return new GraphEdgesCannotBeMerged("because they have different types.");
}
public static GraphEdgesCannotBeMerged becauseTheyHaveDifferentIds() {
return new GraphEdgesCannotBeMerged("because they have different ids.");
}
public static GraphEdgesCannotBeMerged becauseTheyHaveDifferentNodeIds() {
return new GraphEdgesCannotBeMerged("because one or both nodes have different ids.");
}
public static GraphEdgesCannotBeMerged becauseThereIsMultipleEdgesGivenEdgeCouldBeMergeWith(
List<UniqueIdentifier> possibleEdgesToMergeWith) {
return new GraphEdgesCannotBeMerged(
"There is multiple edges with which given edge could be merged with."
+ System.lineSeparator()
+ "Possible edges to be merged with: " +
"[" + StringUtils.join(possibleEdgesToMergeWith, "], [") + "]."
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph/exceptions/GraphNodesCannotBeMerged.java | package ai.stapi.graph.inMemoryGraph.exceptions;
import ai.stapi.graph.exceptions.GraphException;
public class GraphNodesCannotBeMerged extends GraphException {
protected GraphNodesCannotBeMerged(String message) {
super("Graph nodes could not be merged, " + message);
}
public static GraphNodesCannotBeMerged becauseTheyHaveDifferentTypes(
String originalType,
String newType
) {
return new GraphNodesCannotBeMerged(
String.format(
"because they have different types. Original: '%s'. New: '%s'",
originalType,
newType
)
);
}
public static GraphNodesCannotBeMerged becauseTheyHaveDifferentIds() {
return new GraphNodesCannotBeMerged("because they have different ids");
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph/exceptions/MoreThanOneNodeWithAttributeFoundException.java | package ai.stapi.graph.inMemoryGraph.exceptions;
import ai.stapi.graph.exceptions.GraphException;
public class MoreThanOneNodeWithAttributeFoundException extends GraphException {
public MoreThanOneNodeWithAttributeFoundException() {
super("More than one node with attribute found, but expected only one");
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/inMemoryGraph/exceptions/NodeWithAttributeNotFound.java | package ai.stapi.graph.inMemoryGraph.exceptions;
import ai.stapi.graph.exceptions.GraphException;
public class NodeWithAttributeNotFound extends GraphException {
public NodeWithAttributeNotFound() {
super("Node with attribute not found.");
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer/ApiRendererOptions.java | package ai.stapi.graph.renderer.infrastructure.apiRenderer;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
public class ApiRendererOptions implements RendererOptions {
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer/attributes/ApiAttributeVersionsRenderer.java | package ai.stapi.graph.renderer.infrastructure.apiRenderer.attributes;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.reponseGraph.AttributeVersionResponse;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import ai.stapi.graph.versionedAttributes.VersionedAttribute;
import java.util.ArrayList;
public class ApiAttributeVersionsRenderer {
public ArrayList<AttributeVersionResponse> render(
VersionedAttribute<?> attributeVersions,
RendererOptions options
) {
var apiAttributeValueRenders = new ArrayList<AttributeVersionResponse>();
attributeVersions.iterateVersionsFromOldest().forEachRemaining(
attributeVersion -> {
var apiAttributeValueRender = new AttributeVersionResponse(attributeVersion);
apiAttributeValueRenders.add(0, apiAttributeValueRender);
}
);
return apiAttributeValueRenders;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer/attributes/ApiAttributesRenderer.java | package ai.stapi.graph.renderer.infrastructure.apiRenderer.attributes;
import ai.stapi.graph.attribute.AbstractAttributeContainer;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.reponseGraph.AttributeResponse;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
public class ApiAttributesRenderer {
private ApiAttributeVersionsRenderer apiAttributeVersionsRenderer;
@Autowired
public ApiAttributesRenderer(ApiAttributeVersionsRenderer apiAttributeVersionsRenderer) {
this.apiAttributeVersionsRenderer = apiAttributeVersionsRenderer;
}
public ArrayList<AttributeResponse> render(
AbstractAttributeContainer attributeContainer,
RendererOptions options
) {
var attributes = new ArrayList<AttributeResponse>();
attributeContainer.getVersionedAttributeList().forEach(
(versionedAttribute) -> {
var apiAttributeValueRenders = this.apiAttributeVersionsRenderer.render(
versionedAttribute,
options
);
var apiAttributeRender = new AttributeResponse(
versionedAttribute.getName(),
apiAttributeValueRenders
);
attributes.add(apiAttributeRender);
}
);
return attributes;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer/edge/ApiEdgeRenderer.java | package ai.stapi.graph.renderer.infrastructure.apiRenderer.edge;
import ai.stapi.graph.exceptions.NodeNotFound;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.attributes.ApiAttributesRenderer;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.node.ApiCompactNodeRenderer;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.reponseGraph.EdgeResponse;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import ai.stapi.graph.traversableGraphElements.TraversableEdge;
import ai.stapi.graph.traversableGraphElements.TraversableNode;
import org.springframework.beans.factory.annotation.Autowired;
public class ApiEdgeRenderer {
private final ApiCompactNodeRenderer apiCompactNodeRenderer;
private final ApiAttributesRenderer apiAttributesRenderer;
@Autowired
public ApiEdgeRenderer(
ApiCompactNodeRenderer apiCompactNodeRenderer,
ApiAttributesRenderer apiAttributesRenderer
) {
this.apiCompactNodeRenderer = apiCompactNodeRenderer;
this.apiAttributesRenderer = apiAttributesRenderer;
}
public EdgeResponse render(TraversableEdge edge, RendererOptions options) {
TraversableNode nodeFrom;
try {
nodeFrom = edge.getNodeFrom();
} catch (NodeNotFound e) {
nodeFrom = edge.getNodeFrom();
}
var compactNodeFrom = this.apiCompactNodeRenderer.render(nodeFrom);
TraversableNode nodeTo;
try {
nodeTo = edge.getNodeTo();
} catch (NodeNotFound e) {
nodeTo = edge.getNodeTo();
}
var compactNodeTo = this.apiCompactNodeRenderer.render(nodeTo);
var attributes = this.apiAttributesRenderer.render(
edge,
options
);
return new EdgeResponse(
edge.getId().toString(),
edge.getType(),
compactNodeFrom,
compactNodeTo,
attributes
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer/node/ApiCompactNodeRenderer.java | package ai.stapi.graph.renderer.infrastructure.apiRenderer.node;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.ApiRendererOptions;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.attributes.ApiAttributesRenderer;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.reponseGraph.CompactNodeResponse;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import ai.stapi.graph.traversableGraphElements.TraversableNode;
import org.springframework.beans.factory.annotation.Autowired;
public class ApiCompactNodeRenderer {
private final ApiAttributesRenderer apiAttributesRenderer;
private final ApiNodePrimaryNameFactory apiNodePrimaryNameFactory;
@Autowired
public ApiCompactNodeRenderer(
ApiAttributesRenderer apiAttributesRenderer,
ApiNodePrimaryNameFactory apiNodePrimaryNameFactory
) {
this.apiAttributesRenderer = apiAttributesRenderer;
this.apiNodePrimaryNameFactory = apiNodePrimaryNameFactory;
}
public CompactNodeResponse render(TraversableNode node) {
return this.render(
node,
new ApiRendererOptions()
);
}
public CompactNodeResponse render(TraversableNode node, RendererOptions options) {
var attributes = this.apiAttributesRenderer.render(
node,
options
);
return new CompactNodeResponse(
node.getId().toString(),
node.getType(),
this.apiNodePrimaryNameFactory.createNodePrimaryName(node),
attributes
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer/node/ApiNodePrimaryNameFactory.java | package ai.stapi.graph.renderer.infrastructure.apiRenderer.node;
import ai.stapi.graph.traversableGraphElements.TraversableNode;
import java.util.UUID;
public class ApiNodePrimaryNameFactory {
public String createNodePrimaryName(TraversableNode node) {
try {
UUID.fromString(node.getId().toString());
} catch (IllegalArgumentException e) {
return node.getId().toString();
}
if (node.hasAttribute("name")) {
return node.getAttribute("name").getValue().toString();
}
if (node.hasAttribute("path")) {
return node.getAttribute("path").getValue().toString();
}
return node.getId().toString();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer/node/ApiNodeRenderer.java | package ai.stapi.graph.renderer.infrastructure.apiRenderer.node;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.ApiRendererOptions;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.attributes.ApiAttributesRenderer;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.edge.ApiEdgeRenderer;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.reponseGraph.EdgeResponse;
import ai.stapi.graph.renderer.infrastructure.apiRenderer.reponseGraph.NodeResponse;
import ai.stapi.graph.renderer.model.RenderOutput;
import ai.stapi.graph.renderer.model.nodeRenderer.NodeRenderer;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import ai.stapi.graph.traversableGraphElements.TraversableNode;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
public class ApiNodeRenderer implements NodeRenderer {
private final ApiAttributesRenderer apiAttributesRenderer;
private final ApiEdgeRenderer apiEdgeRenderer;
private final ApiNodePrimaryNameFactory apiNodePrimaryNameFactory;
@Autowired
public ApiNodeRenderer(
ApiAttributesRenderer apiAttributesRenderer,
ApiEdgeRenderer apiEdgeRenderer,
ApiNodePrimaryNameFactory apiNodePrimaryNameFactory
) {
this.apiAttributesRenderer = apiAttributesRenderer;
this.apiEdgeRenderer = apiEdgeRenderer;
this.apiNodePrimaryNameFactory = apiNodePrimaryNameFactory;
}
@Override
public boolean supports(RendererOptions options) {
return options.getClass().equals(ApiRendererOptions.class);
}
@Override
public RenderOutput render(TraversableNode node) {
return this.render(
node,
new ApiRendererOptions()
);
}
@Override
public RenderOutput render(TraversableNode node, RendererOptions options) {
var attributes = this.apiAttributesRenderer.render(
node,
options
);
var edges = new ArrayList<EdgeResponse>();
node.getEdges().forEach(
edge -> {
edges.add(this.apiEdgeRenderer.render(
edge,
options
));
}
);
return new NodeResponse(
node.getId().toString(),
node.getType(),
this.apiNodePrimaryNameFactory.createNodePrimaryName(node),
attributes,
edges
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer/reponseGraph/AttributeResponse.java | package ai.stapi.graph.renderer.infrastructure.apiRenderer.reponseGraph;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.Serializable;
import java.util.List;
import org.jetbrains.annotations.NotNull;
public class AttributeResponse implements Serializable {
private final String type;
private final List<AttributeVersionResponse> values;
@JsonCreator
public AttributeResponse(@NotNull String type, @NotNull List<AttributeVersionResponse> values) {
this.type = type;
this.values = values;
}
public String getType() {
return type;
}
public List<AttributeVersionResponse> getValues() {
return values;
}
@JsonIgnore
public String getCurrentValue() {
return values.stream()
.findFirst()
.orElseThrow()
.getValue();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer/reponseGraph/AttributeVersionResponse.java | package ai.stapi.graph.renderer.infrastructure.apiRenderer.reponseGraph;
import ai.stapi.graph.attribute.Attribute;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.io.Serializable;
import java.time.Instant;
public class AttributeVersionResponse implements Serializable {
private final String value;
private final Instant createdAt;
public AttributeVersionResponse(Attribute<?> attribute) {
this.value = attribute.getValue().toString();
this.createdAt = attribute.getCreatedAt();
}
@JsonCreator
public AttributeVersionResponse(String value, Instant createdAt) {
this.value = value;
this.createdAt = createdAt;
}
public String getValue() {
return value;
}
public Instant getCreatedAt() {
return createdAt;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer/reponseGraph/CompactNodeResponse.java | package ai.stapi.graph.renderer.infrastructure.apiRenderer.reponseGraph;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.io.Serializable;
import java.util.List;
import org.jetbrains.annotations.NotNull;
public class CompactNodeResponse implements Serializable {
private final String nodeId;
private final String type;
private final String primaryName;
private final List<AttributeResponse> attributes;
@JsonCreator
public CompactNodeResponse(
@NotNull String nodeId,
@NotNull String type,
@NotNull String primaryName,
@NotNull List<AttributeResponse> attributes
) {
this.nodeId = nodeId;
this.type = type;
this.primaryName = primaryName;
this.attributes = attributes;
}
public String getType() {
return type;
}
public String getPrimaryName() {
return primaryName;
}
public List<AttributeResponse> getAttributes() {
return attributes;
}
public String getNodeId() {
return nodeId;
}
public String toString() {
if (!this.type.equals(this.primaryName)) {
return this.getPrimaryName() + " (" + this.getType() + ")";
}
return this.getType();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer/reponseGraph/EdgeResponse.java | package ai.stapi.graph.renderer.infrastructure.apiRenderer.reponseGraph;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.io.Serializable;
import java.util.List;
import org.jetbrains.annotations.NotNull;
public class EdgeResponse implements Serializable {
private final String edgeId;
private final String type;
private final CompactNodeResponse compactNodeFrom;
private final CompactNodeResponse compactNodeTo;
private final List<AttributeResponse> attributes;
@JsonCreator
public EdgeResponse(
@NotNull String edgeId,
@NotNull String type,
@NotNull CompactNodeResponse compactNodeFrom,
@NotNull CompactNodeResponse compactNodeTo,
@NotNull List<AttributeResponse> attributes
) {
this.edgeId = edgeId;
this.type = type;
this.compactNodeFrom = compactNodeFrom;
this.compactNodeTo = compactNodeTo;
this.attributes = attributes;
}
public String getEdgeId() {
return edgeId;
}
public String getType() {
return type;
}
public CompactNodeResponse getCompactNodeFrom() {
return compactNodeFrom;
}
public CompactNodeResponse getCompactNodeTo() {
return compactNodeTo;
}
public List<AttributeResponse> getAttributes() {
return attributes;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/apiRenderer/reponseGraph/NodeResponse.java | package ai.stapi.graph.renderer.infrastructure.apiRenderer.reponseGraph;
import ai.stapi.graph.renderer.model.RenderOutput;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;
public class NodeResponse implements RenderOutput, Serializable {
private final String nodeId;
private final String type;
private final String primaryName;
private final List<AttributeResponse> attributes;
private final List<EdgeResponse> edges;
public NodeResponse(String nodeId, String type, String primaryName) {
this.nodeId = nodeId;
this.type = type;
this.primaryName = primaryName;
this.attributes = new ArrayList<>();
this.edges = new ArrayList<>();
}
public NodeResponse(
@NotNull String nodeId,
@NotNull String type,
@NotNull String primaryName,
@NotNull List<AttributeResponse> attributes
) {
this.nodeId = nodeId;
this.type = type;
this.primaryName = primaryName;
this.attributes = attributes;
this.edges = new ArrayList<>();
}
@JsonCreator
public NodeResponse(
@NotNull String nodeId,
@NotNull String type,
@NotNull String primaryName,
List<AttributeResponse> attributes,
@NotNull List<EdgeResponse> edges
) {
this.nodeId = nodeId;
this.type = type;
this.primaryName = primaryName;
this.attributes = attributes.stream().sorted(
Comparator.comparing(AttributeResponse::getType)
).collect(Collectors.toList());
this.edges = edges;
}
public String getType() {
return type;
}
public String getPrimaryName() {
return primaryName;
}
public List<AttributeResponse> getAttributes() {
return attributes;
}
public List<EdgeResponse> getEdges() {
return edges;
}
public String getNodeId() {
return nodeId;
}
@Override
public String toPrintableString() {
return "ApiNodeRender{"
+ "nodeId='" + nodeId + '\''
+ ", type='" + type + '\''
+ ", primaryName='" + primaryName + '\''
+ ", attributes=" + attributes
+ ", edges=" + edges
+ '}';
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/idLessTextRenderer/IdLessTextGraphRenderer.java | package ai.stapi.graph.renderer.infrastructure.idLessTextRenderer;
import ai.stapi.graph.Graph;
import ai.stapi.graph.inMemoryGraph.InMemoryGraphRepository;
import ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.edge.IdLessTextEdgeRenderer;
import ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.node.IdLessTextNodeRenderer;
import ai.stapi.graph.renderer.model.GraphRenderOutput;
import ai.stapi.graph.renderer.model.GraphRenderer;
import ai.stapi.graph.renderer.model.StringGraphRenderOutput;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import ai.stapi.graph.traversableGraphElements.TraversableNode;
import ai.stapi.utils.LineFormatter;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
public class IdLessTextGraphRenderer implements GraphRenderer {
private final IdLessTextNodeRenderer idLessTextNodeRenderer;
private final IdLessTextEdgeRenderer idLessTextEdgeRenderer;
@Autowired
public IdLessTextGraphRenderer(
IdLessTextNodeRenderer idLessTextNodeRenderer,
IdLessTextEdgeRenderer idLessTextEdgeRenderer
) {
this.idLessTextNodeRenderer = idLessTextNodeRenderer;
this.idLessTextEdgeRenderer = idLessTextEdgeRenderer;
}
@Override
public GraphRenderOutput render(InMemoryGraphRepository graph) {
return this.render(
graph,
new IdLessTextRendererOptions()
);
}
public GraphRenderOutput render(Graph graph) {
return this.render(
new InMemoryGraphRepository(graph),
new IdLessTextRendererOptions()
);
}
@Override
public GraphRenderOutput render(
InMemoryGraphRepository graph,
RendererOptions options
) {
var idLessRendererOptions = (IdLessTextRendererOptions) options;
var nodesTitle = LineFormatter.createLine(
"nodes:",
idLessRendererOptions.getIndentLevel()
);
var renderedNodes = this.getRenderedNodesString(
graph,
idLessRendererOptions
);
var edgesTitle = LineFormatter.createLine(
"edges:",
idLessRendererOptions.getIndentLevel()
);
var renderedEdges = this.getRenderedEdgeString(
graph,
idLessRendererOptions
);
return new StringGraphRenderOutput(
nodesTitle + renderedNodes + LineFormatter.createNewLine() + edgesTitle + renderedEdges);
}
@Override
public boolean supports(RendererOptions options) {
return options instanceof IdLessTextRendererOptions;
}
private String getRenderedNodesString(InMemoryGraphRepository graph,
IdLessTextRendererOptions options) {
List<TraversableNode> traversableNodes = graph.loadAllNodes();
return traversableNodes.stream()
.sorted(Comparator.comparing(
node -> node.getSortingNameWithNodeTypeFallback() + node.getIdlessHashCodeWithEdges())
).map(node -> idLessTextNodeRenderer.render(
node,
new IdLessTextRendererOptions(
options.getIndentLevel() + 1,
options.getNodeRelationAnnotationAttributeName().orElse("")
)
).toPrintableString()
).sorted()
.collect(Collectors.joining(LineFormatter.createNewLine()));
}
private String getRenderedEdgeString(InMemoryGraphRepository graph,
IdLessTextRendererOptions options) {
return graph.loadAllEdges().stream()
.map(edge -> idLessTextEdgeRenderer.render(
edge,
new IdLessTextRendererOptions(
options.getIndentLevel() + 1,
options.getNodeRelationAnnotationAttributeName().orElse("")
)
).toPrintableString())
.sorted()
.collect(Collectors.joining(LineFormatter.createNewLine()));
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/idLessTextRenderer/IdLessTextRendererOptions.java | package ai.stapi.graph.renderer.infrastructure.idLessTextRenderer;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import java.util.Optional;
public class IdLessTextRendererOptions implements RendererOptions {
private int indentLevel;
private String nodeRelationAnnotationAttributeName;
public IdLessTextRendererOptions() {
this.indentLevel = 0;
this.nodeRelationAnnotationAttributeName = "";
}
public IdLessTextRendererOptions(int indentLevel) {
this.indentLevel = indentLevel;
this.nodeRelationAnnotationAttributeName = "";
}
public IdLessTextRendererOptions(int indentLevel, String attributeToRenderInRelationsName) {
this.indentLevel = indentLevel;
this.nodeRelationAnnotationAttributeName = attributeToRenderInRelationsName;
}
public IdLessTextRendererOptions(String attributeToRenderInRelationsName) {
this.indentLevel = 0;
this.nodeRelationAnnotationAttributeName = attributeToRenderInRelationsName;
}
public int getIndentLevel() {
return indentLevel;
}
public Optional<String> getNodeRelationAnnotationAttributeName() {
if (this.nodeRelationAnnotationAttributeName.isBlank()) {
return Optional.empty();
}
return Optional.of(nodeRelationAnnotationAttributeName);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/idLessTextRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/idLessTextRenderer/attribute/TextAttributeContainerRenderer.java | package ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.attribute;
import ai.stapi.graph.attribute.AbstractAttributeContainer;
import ai.stapi.graph.renderer.infrastructure.textRenderer.TextRendererOptions;
import ai.stapi.graph.renderer.infrastructure.textRenderer.node.TextNodeRenderOutput;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import ai.stapi.utils.LineFormatter;
import java.util.stream.Collectors;
public class TextAttributeContainerRenderer {
public TextNodeRenderOutput render(AbstractAttributeContainer attributeContainer,
RendererOptions options) {
var downtypedOptions = (TextRendererOptions) options;
var indentLevel = downtypedOptions.getIndentLevel();
return new TextNodeRenderOutput(
LineFormatter.createLine(
"attributes:",
indentLevel
) + attributeContainer.getFlattenAttributes().stream()
.map(attribute -> attribute.getName() + " -> " + attribute.getValue())
.map(line -> LineFormatter.createLine(
line,
indentLevel + 1
))
.sorted()
.collect(Collectors.joining())
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/idLessTextRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/idLessTextRenderer/edge/IdLessTextEdgeRenderer.java | package ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.edge;
import ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.IdLessTextRendererOptions;
import ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.attribute.TextAttributeContainerRenderer;
import ai.stapi.graph.renderer.infrastructure.textRenderer.TextRendererOptions;
import ai.stapi.graph.renderer.model.edgeRenderer.EdgeRenderer;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import ai.stapi.graph.traversableGraphElements.TraversableEdge;
import ai.stapi.utils.LineFormatter;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
public class IdLessTextEdgeRenderer implements EdgeRenderer {
private final TextAttributeContainerRenderer textAttributeContainerRenderer;
@Autowired
public IdLessTextEdgeRenderer(TextAttributeContainerRenderer textAttributeContainerRenderer) {
this.textAttributeContainerRenderer = textAttributeContainerRenderer;
}
@Override
public IdlessTextRenderedOutput render(TraversableEdge edge) {
return this.render(
edge,
new IdLessTextRendererOptions()
);
}
@Override
public IdlessTextRenderedOutput render(TraversableEdge edge, RendererOptions options) {
var specificOptions = (IdLessTextRendererOptions) options;
var typeLine = LineFormatter.createLine(
"edge_type: " + edge.getType(),
specificOptions.getIndentLevel()
);
var hashLine = LineFormatter.createLine(
"edge_hash: " + this.formatHashCodeAsString(edge.getIdlessHashCode()),
specificOptions.getIndentLevel()
);
var relationLine = this.getRelationLine(
edge,
specificOptions
);
var attributesLines = textAttributeContainerRenderer.render(
edge,
new TextRendererOptions(specificOptions.getIndentLevel())
).toPrintableString();
return new IdlessTextRenderedOutput(typeLine + hashLine + relationLine + attributesLines);
}
private String getRelationLine(TraversableEdge edge, IdLessTextRendererOptions options) {
var nodeFrom = edge.getNodeFrom();
var nodeTo = edge.getNodeTo();
var typeRelationString = String.format(
"%s -> %s -> %s",
nodeFrom.getType(),
edge.getType(),
nodeTo.getType()
);
var relationString = "";
var attributeName = options.getNodeRelationAnnotationAttributeName();
if (attributeName.isPresent()) {
relationString = this.getAttributeRelationString(
edge,
attributeName.get()
);
} else {
relationString = this.getHashRelationString(edge);
}
return LineFormatter.createLine(typeRelationString + " " + relationString,
options.getIndentLevel());
}
private String formatHashCodeAsString(int hashCode) {
var bytes = DigestUtils.md5(hashCode + "");
var hex = Hex.encodeHex(bytes);
return new String(hex).toUpperCase().substring(0, 5);
}
private String getHashRelationString(TraversableEdge edge) {
return String.format(
"(%s -> %s -> %s)",
this.formatHashCodeAsString(edge.getNodeFrom().getIdlessHashCodeWithEdges()),
this.formatHashCodeAsString(edge.getIdlessHashCode()),
this.formatHashCodeAsString(edge.getNodeTo().getIdlessHashCodeWithEdges())
);
}
private String getAttributeRelationString(TraversableEdge edge, String attributeName) {
var nodeFromTag = "";
var nodeToTag = "";
if (edge.getNodeFrom().hasAttribute(attributeName)) {
nodeFromTag = (String) edge.getNodeFrom().getAttribute(attributeName).getValue();
} else {
nodeFromTag = this.formatHashCodeAsString(edge.getNodeFrom().getIdlessHashCodeWithEdges());
}
if (edge.getNodeTo().hasAttribute(attributeName)) {
nodeToTag = (String) edge.getNodeTo().getAttribute(attributeName).getValue();
} else {
nodeToTag = this.formatHashCodeAsString(edge.getNodeTo().getIdlessHashCodeWithEdges());
}
return String.format(
"(%s -> %s -> %s)",
nodeFromTag,
this.formatHashCodeAsString(edge.getIdlessHashCode()),
nodeToTag
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/idLessTextRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/idLessTextRenderer/edge/IdlessTextRenderedOutput.java | package ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.edge;
import ai.stapi.graph.renderer.model.RenderOutput;
public class IdlessTextRenderedOutput implements RenderOutput {
private String render;
public IdlessTextRenderedOutput(String render) {
this.render = render;
}
@Override
public String toPrintableString() {
return this.render;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/idLessTextRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/idLessTextRenderer/node/IdLessTextNodeRenderOutput.java | package ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.node;
import ai.stapi.graph.renderer.model.RenderOutput;
public class IdLessTextNodeRenderOutput implements RenderOutput {
private String renderedString;
public IdLessTextNodeRenderOutput(String renderedString) {
this.renderedString = renderedString;
}
@Override
public String toPrintableString() {
return renderedString;
}
public void setRenderedString(String renderedString) {
this.renderedString = renderedString;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/idLessTextRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/idLessTextRenderer/node/IdLessTextNodeRenderer.java | package ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.node;
import ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.IdLessTextRendererOptions;
import ai.stapi.graph.renderer.infrastructure.idLessTextRenderer.attribute.TextAttributeContainerRenderer;
import ai.stapi.graph.renderer.infrastructure.textRenderer.TextRendererOptions;
import ai.stapi.graph.renderer.model.nodeRenderer.NodeRenderer;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import ai.stapi.graph.traversableGraphElements.TraversableEdge;
import ai.stapi.graph.traversableGraphElements.TraversableNode;
import ai.stapi.utils.LineFormatter;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
public class IdLessTextNodeRenderer implements NodeRenderer {
private final TextAttributeContainerRenderer textAttributeContainerRenderer;
@Autowired
public IdLessTextNodeRenderer(TextAttributeContainerRenderer textAttributeContainerRenderer) {
this.textAttributeContainerRenderer = textAttributeContainerRenderer;
}
@Override
public boolean supports(RendererOptions options) {
return options.getClass().equals(IdLessTextRendererOptions.class);
}
@Override
public IdLessTextNodeRenderOutput render(TraversableNode node) {
return this.render(
node,
new IdLessTextRendererOptions()
);
}
@Override
public IdLessTextNodeRenderOutput render(TraversableNode node, RendererOptions options) {
var downtypedOptions = (IdLessTextRendererOptions) options;
var indentLevel = downtypedOptions.getIndentLevel();
var relationAnnotation = downtypedOptions.getNodeRelationAnnotationAttributeName();
var nodeTypeLine = LineFormatter.createLine(
"node_type: " + node.getType(),
indentLevel
);
var hashLine = LineFormatter.createLine(
"node_hash: " + this.formatHashCodeAsString(node.getIdlessHashCodeWithEdges()),
indentLevel
);
var edgesString = this.getRenderedEdges(
node,
indentLevel,
relationAnnotation
);
var attributesString = this.textAttributeContainerRenderer.render(
node,
new TextRendererOptions(indentLevel)
).toPrintableString();
return new IdLessTextNodeRenderOutput(
nodeTypeLine + hashLine + edgesString + attributesString
);
}
private String formatHashCodeAsString(int hashCode) {
var bytes = DigestUtils.md5(hashCode + "");
var hex = Hex.encodeHex(bytes);
return new String(hex).toUpperCase().substring(0, 5);
}
private String getRenderedEdges(TraversableNode node, int indentLevel,
Optional<String> annotationAttribute) {
var line = LineFormatter.createLine(
"node_edges:",
indentLevel
);
var edges = node.getEdges();
return line + edges.stream()
.map(edge -> this.getRenderedEdge(
edge,
indentLevel + 1,
annotationAttribute
))
.sorted()
.collect(Collectors.joining());
}
private String getRenderedEdge(TraversableEdge edge, int indentLevel,
Optional<String> annotationAttribute) {
var nodeFrom = edge.getNodeFrom();
var nodeTo = edge.getNodeTo();
var typeRelationString = String.format(
"%s -> %s -> %s",
nodeFrom.getType(),
edge.getType(),
nodeTo.getType()
);
var relationString = "";
if (annotationAttribute.isPresent()) {
relationString = this.getAttributeRelationString(edge, annotationAttribute.get());
} else {
relationString = this.getHashRelationString(edge);
}
return LineFormatter.createLine(
typeRelationString + " " + relationString,
indentLevel
);
}
private String getHashRelationString(TraversableEdge edge) {
return String.format(
"(%s -> %s -> %s)",
this.formatHashCodeAsString(edge.getNodeFrom().getIdlessHashCodeWithEdges()),
this.formatHashCodeAsString(edge.getIdlessHashCode()),
this.formatHashCodeAsString(edge.getNodeTo().getIdlessHashCodeWithEdges())
);
}
private String getAttributeRelationString(TraversableEdge edge, String attributeName) {
var nodeFromTag = "";
var nodeToTag = "";
if (edge.getNodeFrom().hasAttribute(attributeName)) {
nodeFromTag = (String) edge.getNodeFrom().getAttribute(attributeName).getValue();
} else {
nodeFromTag = this.formatHashCodeAsString(edge.getNodeFrom().getIdlessHashCodeWithEdges());
}
if (edge.getNodeTo().hasAttribute(attributeName)) {
nodeToTag = (String) edge.getNodeTo().getAttribute(attributeName).getValue();
} else {
nodeToTag = this.formatHashCodeAsString(edge.getNodeTo().getIdlessHashCodeWithEdges());
}
return String.format(
"(%s -> %s -> %s)",
nodeFromTag,
this.formatHashCodeAsString(edge.getIdlessHashCode()),
nodeToTag
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/ResponseGraphRenderer.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer;
import ai.stapi.graph.inMemoryGraph.InMemoryGraphRepository;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.edge.ResponseEdgeRenderer;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.node.ResponseNodeRenderer;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph.ResponseEdge;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph.ResponseGraph;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph.ResponseNode;
import ai.stapi.graph.renderer.model.GraphRenderer;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import java.util.Comparator;
import java.util.LinkedHashMap;
public class ResponseGraphRenderer implements GraphRenderer {
private final ResponseNodeRenderer responseNodeRenderer;
private final ResponseEdgeRenderer responseEdgeRenderer;
public ResponseGraphRenderer(
ResponseNodeRenderer responseNodeRenderer,
ResponseEdgeRenderer responseEdgeRenderer
) {
this.responseNodeRenderer = responseNodeRenderer;
this.responseEdgeRenderer = responseEdgeRenderer;
}
@Override
public boolean supports(RendererOptions options) {
return options instanceof ResponseRendererOptions;
}
@Override
public ResponseGraph render(InMemoryGraphRepository graph) {
return this.render(graph, new ResponseRendererOptions());
}
@Override
public ResponseGraph render(InMemoryGraphRepository graph,
RendererOptions options) {
var nodes = new LinkedHashMap<String, ResponseNode>();
var edges = new LinkedHashMap<String, ResponseEdge>();
graph.loadAllNodes().stream()
.sorted(Comparator.comparing(
node -> node.getSortingNameWithNodeTypeFallback() + node.getIdlessHashCodeWithEdges()))
.map(traversableNode -> this.responseNodeRenderer.render(traversableNode, options))
.forEach(responseNode -> nodes.put(responseNode.getUuid(), responseNode));
graph.loadAllEdges().stream()
.map(traversableEdge -> this.responseEdgeRenderer.render(traversableEdge, options))
.sorted()
.forEach(responseEdge -> edges.put(responseEdge.getUuid(), responseEdge));
return new ResponseGraph(nodes, edges);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/ResponseRendererOptions.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
public class ResponseRendererOptions implements RendererOptions {
public ResponseRendererOptions() {
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/attributes/ResponseAttributeVersionsRenderer.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer.attributes;
import ai.stapi.graph.attribute.Attribute;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph.ResponseAttributeVersion;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import ai.stapi.graph.versionedAttributes.VersionedAttribute;
import java.util.ArrayList;
public class ResponseAttributeVersionsRenderer {
public <T extends Attribute<?>> ArrayList<ResponseAttributeVersion<T>> render(
VersionedAttribute<T> attributeVersions, RendererOptions options) {
var responseAttributeVersions = new ArrayList<ResponseAttributeVersion<T>>();
attributeVersions.iterateVersionsFromOldest().forEachRemaining(
attributeVersion -> {
var responseAttributeVersion = new ResponseAttributeVersion(attributeVersion);
responseAttributeVersions.add(responseAttributeVersion);
}
);
return responseAttributeVersions;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/attributes/ResponseAttributesRenderer.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer.attributes;
import ai.stapi.graph.attribute.AbstractAttributeContainer;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph.ResponseAttribute;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import ai.stapi.graph.versionedAttributes.VersionedAttribute;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
public class ResponseAttributesRenderer {
private final ResponseAttributeVersionsRenderer responseAttributeVersionsRenderer;
@Autowired
public ResponseAttributesRenderer(
ResponseAttributeVersionsRenderer responseAttributeVersionsRenderer) {
this.responseAttributeVersionsRenderer = responseAttributeVersionsRenderer;
}
public Map<String, ResponseAttribute<?>> render(AbstractAttributeContainer attributeContainer,
RendererOptions options) {
return attributeContainer.getVersionedAttributeList().stream()
.map(attribute -> this.renderResponseAttribute(options, attribute))
.collect(Collectors.toMap(ResponseAttribute::getName, Function.identity()));
}
@NotNull
private ResponseAttribute<?> renderResponseAttribute(RendererOptions options,
VersionedAttribute<?> attribute) {
return new ResponseAttribute<>(attribute.getName(),
this.responseAttributeVersionsRenderer.render(attribute, options));
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/edge/ResponseEdgeRenderer.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer.edge;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.ResponseRendererOptions;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.attributes.ResponseAttributesRenderer;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph.ResponseEdge;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph.ResponseNodeIdAndType;
import ai.stapi.graph.renderer.model.edgeRenderer.EdgeRenderer;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import ai.stapi.graph.traversableGraphElements.TraversableEdge;
import org.springframework.beans.factory.annotation.Autowired;
public class ResponseEdgeRenderer implements EdgeRenderer {
private final ResponseAttributesRenderer responseAttributesRenderer;
@Autowired
public ResponseEdgeRenderer(ResponseAttributesRenderer responseAttributesRenderer) {
this.responseAttributesRenderer = responseAttributesRenderer;
}
@Override
public ResponseEdge render(TraversableEdge edge) {
return this.render(edge, new ResponseRendererOptions());
}
public ResponseEdge render(TraversableEdge edge, RendererOptions options) {
var attributes = this.responseAttributesRenderer.render(
edge,
options
);
return new ResponseEdge(
edge.getId().toString(),
edge.getType(),
new ResponseNodeIdAndType(edge.getNodeFromId().toString(), edge.getNodeFromType()),
new ResponseNodeIdAndType(edge.getNodeFromId().toString(), edge.getNodeFromType()),
attributes
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/node/ResponseNodeRenderer.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer.node;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.ResponseRendererOptions;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.attributes.ResponseAttributesRenderer;
import ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph.ResponseNode;
import ai.stapi.graph.renderer.model.nodeRenderer.NodeRenderer;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
import ai.stapi.graph.traversableGraphElements.TraversableNode;
import org.springframework.beans.factory.annotation.Autowired;
public class ResponseNodeRenderer implements NodeRenderer {
private final ResponseAttributesRenderer responseAttributesRenderer;
@Autowired
public ResponseNodeRenderer(ResponseAttributesRenderer responseAttributesRenderer) {
this.responseAttributesRenderer = responseAttributesRenderer;
}
@Override
public boolean supports(RendererOptions options) {
return options.getClass().equals(ResponseRendererOptions.class);
}
@Override
public ResponseNode render(TraversableNode node) {
return this.render(
node,
new ResponseRendererOptions()
);
}
@Override
public ResponseNode render(TraversableNode node, RendererOptions options) {
var attributes = this.responseAttributesRenderer.render(
node,
options
);
return new ResponseNode(
node.getId().toString(),
node.getType(),
attributes
);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/responseGraph/ResponseAttribute.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph;
import java.util.ArrayList;
import java.util.Objects;
public class ResponseAttribute<T> {
private String name;
private ArrayList<ResponseAttributeVersion<T>> values;
private ResponseAttribute() {
}
public ResponseAttribute(String name, ArrayList<ResponseAttributeVersion<T>> values) {
this.name = name;
this.values = values;
}
public String getName() {
return name;
}
public ArrayList<ResponseAttributeVersion<T>> getValues() {
return values;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ResponseAttribute<?> that = (ResponseAttribute<?>) o;
return name.equals(that.name) && values.equals(that.values);
}
@Override
public int hashCode() {
return Objects.hash(name, values);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/responseGraph/ResponseAttributeVersion.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph;
import ai.stapi.graph.attribute.Attribute;
import java.time.Instant;
import java.util.Objects;
public class ResponseAttributeVersion<T> {
private T value;
private Instant createdAt;
private ResponseAttributeVersion() {
}
public ResponseAttributeVersion(Attribute<T> attribute) {
this.value = attribute.getValue();
this.createdAt = attribute.getCreatedAt();
}
public T getValue() {
return value;
}
public Instant getCreatedAt() {
return createdAt;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ResponseAttributeVersion<?> that = (ResponseAttributeVersion<?>) o;
return value.equals(that.value) && createdAt.equals(that.createdAt);
}
@Override
public int hashCode() {
return Objects.hash(value, createdAt);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/responseGraph/ResponseEdge.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph;
import ai.stapi.graph.renderer.model.RenderOutput;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
public class ResponseEdge implements RenderOutput, Comparable<ResponseEdge> {
private String uuid;
private String type;
private ResponseNodeIdAndType nodeFrom;
private ResponseNodeIdAndType nodeTo;
private Map<String, ResponseAttribute<?>> attributes;
private ResponseEdge() {
}
public ResponseEdge(
String uuid,
String type,
ResponseNodeIdAndType nodeFrom,
ResponseNodeIdAndType nodeTo,
Map<String, ResponseAttribute<?>> attributes
) {
this.uuid = uuid;
this.type = type;
this.nodeFrom = nodeFrom;
this.nodeTo = nodeTo;
this.attributes = attributes;
}
public ResponseEdge(
String uuid,
String type,
ResponseNodeIdAndType nodeFrom,
ResponseNodeIdAndType nodeTo
) {
this(uuid, type, nodeFrom, nodeTo, new HashMap<>());
}
@NotNull
public String getUuid() {
return uuid;
}
@NotNull
public String getType() {
return type;
}
@NotNull
public ResponseNodeIdAndType getNodeFrom() {
return nodeFrom;
}
@NotNull
public ResponseNodeIdAndType getNodeTo() {
return nodeTo;
}
@NotNull
public Map<String, ResponseAttribute<?>> getAttributes() {
return attributes;
}
@Override
public String toString() {
return "ResponseEdge{"
+ "edgeId='" + uuid + '\''
+ ", type='" + type + '\''
+ ", nodeFrom=" + nodeFrom
+ ", nodeTo=" + nodeTo
+ ", attributes=" + attributes
+ '}';
}
@Override
public String toPrintableString() {
return this.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ResponseEdge that = (ResponseEdge) o;
return type.equals(that.type) && nodeFrom.equals(that.nodeFrom) && nodeTo.equals(that.nodeTo)
&& attributes.equals(that.attributes);
}
@Override
public int hashCode() {
return Objects.hash(type, nodeFrom, nodeTo, attributes);
}
@Override
public int compareTo(@NotNull ResponseEdge o) {
return this.hashCode() - o.hashCode();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/responseGraph/ResponseEdgeIdAndType.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph;
import java.util.Objects;
public class ResponseEdgeIdAndType {
private String edgeId;
private String edgeType;
private ResponseEdgeIdAndType() {
}
public ResponseEdgeIdAndType(String edgeId, String edgeType) {
this.edgeId = edgeId;
this.edgeType = edgeType;
}
public String getEdgeId() {
return edgeId;
}
public String getEdgeType() {
return edgeType;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ResponseEdgeIdAndType that = (ResponseEdgeIdAndType) o;
return edgeType.equals(that.edgeType);
}
@Override
public int hashCode() {
return Objects.hash(edgeType);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/responseGraph/ResponseGraph.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph;
import ai.stapi.graph.renderer.model.GraphRenderOutput;
import java.util.HashMap;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
public class ResponseGraph implements GraphRenderOutput {
private final Map<String, ResponseNode> nodes;
private final Map<String, ResponseEdge> edges;
public ResponseGraph() {
this.nodes = new HashMap<>();
this.edges = new HashMap<>();
}
public ResponseGraph(
Map<String, ResponseNode> nodes,
Map<String, ResponseEdge> edges
) {
this.nodes = nodes;
this.edges = edges;
}
@Override
public String toString() {
return "ResponseGraph{"
+ "nodes=" + nodes
+ ", edges=" + edges
+ '}';
}
@Override
public String toPrintableString() {
return this.toString();
}
@NotNull
public Map<String, ResponseNode> getNodes() {
return nodes;
}
@NotNull
public Map<String, ResponseEdge> getEdges() {
return edges;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/responseGraph/ResponseNode.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph;
import ai.stapi.graph.renderer.model.RenderOutput;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
public class ResponseNode implements RenderOutput, Comparable<ResponseNode> {
private String uuid;
private String type;
private Map<String, ResponseAttribute<?>> attributes;
private ResponseNode() {
}
public ResponseNode(
String uuid,
String type,
Map<String, ResponseAttribute<?>> attributes
) {
this.uuid = uuid;
this.type = type;
this.attributes = attributes;
}
public ResponseNode(String uuid, String type) {
this(uuid, type, new HashMap<>());
}
@NotNull
public String getUuid() {
return uuid;
}
@NotNull
public String getType() {
return type;
}
@NotNull
public Map<String, ResponseAttribute<?>> getAttributes() {
return attributes;
}
@Override
public String toString() {
return "ResponseNode{"
+ "nodeId='" + uuid + '\''
+ ", type='" + type + '\''
+ ", attributes=" + attributes
+ '}';
}
@Override
public String toPrintableString() {
return this.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ResponseNode that = (ResponseNode) o;
return type.equals(that.type) && attributes.equals(that.attributes);
}
@Override
public int hashCode() {
return Objects.hash(type, attributes);
}
@Override
public int compareTo(@NotNull ResponseNode o) {
return this.hashCode() - o.hashCode();
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/responseRenderer/responseGraph/ResponseNodeIdAndType.java | package ai.stapi.graph.renderer.infrastructure.responseRenderer.responseGraph;
import java.util.Objects;
public class ResponseNodeIdAndType {
private String nodeId;
private String nodeType;
private ResponseNodeIdAndType() {
}
public ResponseNodeIdAndType(String nodeId, String nodeType) {
this.nodeId = nodeId;
this.nodeType = nodeType;
}
public String getNodeId() {
return nodeId;
}
public String getNodeType() {
return nodeType;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ResponseNodeIdAndType that = (ResponseNodeIdAndType) o;
return nodeType.equals(that.nodeType);
}
@Override
public int hashCode() {
return Objects.hash(nodeType);
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/textRenderer/TextRendererOptions.java | package ai.stapi.graph.renderer.infrastructure.textRenderer;
import ai.stapi.graph.renderer.model.nodeRenderer.RendererOptions;
public class TextRendererOptions implements RendererOptions {
private int indentLevel;
public TextRendererOptions() {
this.indentLevel = 0;
}
public TextRendererOptions(int indentLevel) {
this.indentLevel = indentLevel;
}
public int getIndentLevel() {
return indentLevel;
}
}
|
0 | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/textRenderer | java-sources/ai/stapi/graph/0.3.2/ai/stapi/graph/renderer/infrastructure/textRenderer/edge/TextEdgeRenderOutput.java | package ai.stapi.graph.renderer.infrastructure.textRenderer.edge;
import ai.stapi.graph.renderer.model.RenderOutput;
public class TextEdgeRenderOutput implements RenderOutput {
private String output;
public TextEdgeRenderOutput(String output) {
this.output = output;
}
@Override
public String toPrintableString() {
return this.output;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.