Esempio n. 1
0
 public void save() {
   LoggerFactory.getLogger(ScanGraphStore.class).info("Persisting graphs of components");
   BatchSession session = myBatis.openBatchSession();
   GraphDtoMapper mapper = session.getMapper(GraphDtoMapper.class);
   try {
     for (ComponentVertex component : projectGraph.getComponents()) {
       Long snapshotId = (Long) component.element().getProperty("sid");
       if (snapshotId != null) {
         for (PerspectiveBuilder builder : builders) {
           Perspective perspective = builder.load(component);
           if (perspective != null) {
             Graph subGraph = SubGraph.extract(component.element(), builder.path());
             String data = write(subGraph);
             mapper.insert(
                 new GraphDto()
                     .setData(data)
                     .setFormat("graphson")
                     .setPerspective(builder.getPerspectiveKey())
                     .setVersion(1)
                     .setResourceId((Long) component.element().getProperty("rid"))
                     .setSnapshotId(snapshotId)
                     .setRootVertexId(component.element().getId().toString()));
           }
         }
       }
     }
     session.commit();
   } finally {
     session.close();
   }
 }