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

Error when updating a vertex #268

Open
kyeljmd opened this issue Nov 25, 2018 · 1 comment
Open

Error when updating a vertex #268

kyeljmd opened this issue Nov 25, 2018 · 1 comment

Comments

@kyeljmd
Copy link

kyeljmd commented Nov 25, 2018

Here is the error that I am encountering.

play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[IllegalStateException: Property addition is not supported]] at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:251) at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:178) at play.core.server.AkkaHttpServer$$anonfun$1.applyOrElse(AkkaHttpServer.scala:363) at play.core.server.AkkaHttpServer$$anonfun$1.applyOrElse(AkkaHttpServer.scala:361) at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:413) at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37) at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60) at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55) at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12) Caused by: java.lang.IllegalStateException: Property addition is not supported at org.apache.tinkerpop.gremlin.structure.Element$Exceptions.propertyAdditionNotSupported(Element.java:133) at org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex.property(DetachedVertex.java:91) at org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex.property(DetachedVertex.java:50) at gremlin.scala.ScalaElement.$anonfun$updateWith$2(ScalaElement.scala:76) at scala.collection.immutable.HashMap$HashMap1.foreach(HashMap.scala:231) at scala.collection.immutable.HashMap$HashTrieMap.foreach(HashMap.scala:462) at gremlin.scala.ScalaElement.updateWith(ScalaElement.scala:76) at gremlin.scala.ScalaElement.updateWith$(ScalaElement.scala:70) at gremlin.scala.ScalaVertex.updateWith(ScalaVertex.scala:8) at gremlin.scala.ScalaElement.updateAs(ScalaElement.scala:82)

Here are my models and the way I have defined it.

import java.util. UUID
import gremlin.scala.{Element, Marshallable, Vertex, id, label, underlying}


@label("trip")
case class TripModel(tripId: Option[String] = None,
                     name: String,
                     createdDate: java.time.Instant = java.time.Instant.now(),
                     startDate: java.time.Instant,
                     duration: Int,
                     totalAdults: Int,
                     totalChildrens: Int,
                     @underlying vertex: Option[Vertex] = None
                    )

object TripModel {

  implicit val marshaller = new Marshallable[TripModel] {
    def toCC(element: Element): TripModel = {
      val tripId = Some(element.value[UUID]("tripId").toString)
      val tripName = element.value[String]("name")
      val duration =  element.value[Int]("duration")
      val totalAdults = element.value[Short]("totalAdults")
      val totalChildren =element.value[Short]("totalChildrens")
      val date = element.value[java.time.Instant]("createdDate")
      val startDate = element.value[java.time.Instant]("startDate")

      models.TripModel(tripId = tripId, name = tripName,
        startDate  = startDate, duration = duration,
        totalAdults = totalAdults, totalChildrens = totalChildren, createdDate = date)
    }

    override def fromCC(cc: TripModel): FromCC = {
      val values = Map("name" -> cc.name,
        "createdDate" -> cc.createdDate,
        "startDate" -> cc.startDate,
        "duration"-> cc.duration,
        "totalAdults" -> cc.totalAdults,
        "totalChildrens" -> cc.totalChildrens,
        "tripId" -> UUID.fromString(cc.tripId.get).toString)
      FromCC(None, "trip", values)
    }
  }
}

And here is how I update a certain field.

  def updateTripDetails(id:String, tripUpdate: UpdateTripRequest) = {
    implicit val g = db.g

    val item = db.g.V().has(KeyValue(tripId, id)).head
    item.updateAs[TripModel](cc => cc.copy(name = tripUpdate.tripName.getOrElse(cc.name)))
  }

What I am trying to do is to update a certain vertex property, however I always received the aforementioned error. is there any workaround for this?

@kyeljmd kyeljmd changed the title Updating a Property results into Property Addition Not Supported Error when updating a vertex Nov 29, 2018
@kyeljmd
Copy link
Author

kyeljmd commented Nov 29, 2018

bumping this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant