Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to the angulillos-0.7 #21

Merged
merged 6 commits into from
May 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ bucketSuffix := "era7.com"
javaVersion := "1.8"

libraryDependencies ++= Seq(
"bio4j" % "angulillos" % "0.6.0",
"bio4j" % "angulillos" % "0.7.0",
"com.thinkaurelius.titan" % "titan-core" % "1.0.0"
)

excludeFilter in unmanagedSources :=
(excludeFilter in unmanagedSources).value ||
"*Index.java"
89 changes: 89 additions & 0 deletions src/main/java/com/bio4j/angulillos/titan/TitanConversions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.bio4j.angulillos.titan;

import com.bio4j.angulillos.QueryPredicate;
import com.bio4j.angulillos.Arity;

import com.thinkaurelius.titan.core.attribute.Cmp;
import com.thinkaurelius.titan.core.attribute.Contain;
import com.thinkaurelius.titan.core.Multiplicity;
import com.thinkaurelius.titan.core.Cardinality;


public final class TitanConversions {

public static final class Predicate {

public static final Cmp asTitanCmp(QueryPredicate.Compare predicate) {
switch(predicate) {
case EQUAL: return Cmp.EQUAL;
case NOT_EQUAL: return Cmp.NOT_EQUAL;
case GREATER_THAN: return Cmp.GREATER_THAN;
case GREATER_THAN_EQUAL: return Cmp.GREATER_THAN_EQUAL;
case LESS_THAN: return Cmp.LESS_THAN;
case LESS_THAN_EQUAL: return Cmp.LESS_THAN_EQUAL;
// NOTE: this shouldn't happen, because we pattern match on all cases of a sealed enum
default: return Cmp.EQUAL;
}
}

public static final Contain asTitanContain(QueryPredicate.Contain predicate) {
switch(predicate) {
case IN: return Contain.IN;
case NOT_IN: return Contain.NOT_IN;
// NOTE: this shouldn't happen, because we pattern match on all cases of a sealed enum
default: return Contain.IN;
}
}

}

public static final class Arities {
// One/AtMostOne -> ONE
// AtLeastOne/Any -> MANY
// default case represents arity Any

// NOTE: we don't support non-single cardinality in the angulillos API
// public static final Cardinality asTitanCardinality(Arity arity) {
// switch(arity) {
// case One: return Cardinality.SINGLE;
// case AtMostOne: return Cardinality.SINGLE;
// default: return Cardinality.LIST;
// }
// }

public static final Multiplicity asTitanMultiplicity(Arity fromArity, Arity toArity) {
switch(fromArity) {

case One: switch (toArity) {
case One: return Multiplicity.ONE2ONE;
case AtMostOne: return Multiplicity.ONE2ONE;
case AtLeastOne: return Multiplicity.ONE2MANY;
default: return Multiplicity.ONE2MANY;
}

case AtMostOne: switch (toArity) {
case One: return Multiplicity.ONE2ONE;
case AtMostOne: return Multiplicity.ONE2ONE;
case AtLeastOne: return Multiplicity.ONE2MANY;
default: return Multiplicity.ONE2MANY;
}

case AtLeastOne: switch (toArity) {
case One: return Multiplicity.MANY2ONE;
case AtMostOne: return Multiplicity.MANY2ONE;
case AtLeastOne: return Multiplicity.MULTI;
default: return Multiplicity.MULTI;
}

default: switch(toArity) {
case One: return Multiplicity.MANY2ONE;
case AtMostOne: return Multiplicity.MANY2ONE;
case AtLeastOne: return Multiplicity.MULTI;
default: return Multiplicity.MULTI;
}
}
}

}

}

This file was deleted.

Loading