Exemplo n.º 1
0
 private Geometry parseGeometryFile(File file) {
   try {
     Geometry geo = mapper.readValue(file, Geometry.class);
     int sortIndex = 0;
     for (Material mat : geo.getMaterials()) {
       mat.setName(mat.getDbgName());
       mat.setSortIndex(sortIndex++);
     }
     Map<Integer, Material> matMap = MaterialDAO.mapAndSave(geo.getMaterials());
     GeometryDAO.createGeoMaterials(geo, matMap);
     return geo;
   } catch (IOException e) {
     log().error("Failed to parse geometry file:", e);
   }
   return null;
 }
Exemplo n.º 2
0
 protected void updateEntity(File file, E model) {
   try {
     if (PropertyUtils.isReadable(model, "geometry")) {
       Geometry geo = (Geometry) PropertyUtils.getProperty(model, "geometry");
       if (geo == null
           || geo.getUdate() == null
           || geo.getUdate().getTime() < file.lastModified()) {
         Geometry newGeo = parseGeometryFile(file);
         newGeo = syncGeometry(geo, newGeo);
         PropertyUtils.setProperty(model, "geometry", newGeo);
         updateGeo = true;
       }
     } else {
       log().warn(String.format("Property geometry not found on class <%s>", model.getClass()));
     }
     updateByOpts(file, model);
   } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
     log().error(String.format("Failed to update %s with %s", file, model), e);
   }
 }
Exemplo n.º 3
0
 private Geometry syncGeometry(Geometry geo, Geometry newGeo) {
   if (geo != null && geo.getId() != null) {
     log().info("Sync geo Id: " + geo.getId());
     newGeo.setId(geo.getId());
     newGeo.setVersion(geo.getVersion());
     if (newGeo.getGeoMaterials().equals(geo.getGeoMaterials())) {
       newGeo.setGeoMaterials(geo.getGeoMaterials());
     }
     newGeo.getMetadata().setId(geo.getMetadata().getId());
     newGeo.setMetadata(JPA.em().merge(newGeo.getMetadata()));
     newGeo.setMeshes(geo.getMeshes());
     newGeo.setCdate(geo.getCdate());
     newGeo = JPA.em().merge(newGeo);
   }
   return newGeo;
 }