import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.openecomp.sdc.asdctool.impl.migration.MigrationMsg;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationUtils;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import java.util.stream.Collectors;
import static fj.data.List.list;
+import static org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationUtils.handleError;
public class UserStatesMigration extends JsonModelMigration<Edge> {
}
@Override
- Either<Edge, TitanOperationStatus> save(Edge userState) {
+ boolean save(Edge userState) {
Either<InOutVertices, TitanOperationStatus> titanVertices = findEdgeInOutVerticesInNewGraph(userState);
- return titanVertices.left().bind(inOutVertices -> genericDaoMigration.copyEdge(inOutVertices.getOutVertex(), inOutVertices.getInVertex(), userState));
+ return titanVertices.either(inOutVertices -> saveUserState(inOutVertices, userState),
+ err -> handleError(String.format("could not find user edge %s in vertx. error: %s", userState.label(), err.name())));
+ }
+
+ private boolean saveUserState(InOutVertices inOutVertices, Edge userState) {
+ return genericDaoMigration.copyEdge(inOutVertices.getOutVertex(), inOutVertices.getInVertex(), userState)
+ .either(edge -> true,
+ err -> handleError(String.format("failed to save user state edge %s. reason: %s", userState.label(), err.name())));
}
@Override
String vertexUniqueId = getVertexUniqueId(vertex);
LOGGER.debug(String.format("fetching vertex %s from new graph", vertexUniqueId));
return genericDaoMigration.getVertexByProperty(vertexUniqueId, vertex.property(vertexUniqueId).value())
- .right().map(err -> MigrationUtils.handleError(err, String.format("could not find vertex %s in new graph.", vertexUniqueId))) ;
+ .right().map(err -> handleError(err, String.format("could not find vertex %s in new graph.", vertexUniqueId))) ;
}
// private boolean deleteAllEdges(UserData userData, Direction direction) {
TitanVertex getInVertex() {
return inVertex;
}
+
}
}