use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project BIMserver by opensourceBIM.
the class GenerateGeometryLibrary method generate.
private void generate(EPackage ePackage, Schema schema) {
this.ePackage = ePackage;
packageMetaData = new PackageMetaData(ePackage, schema, Paths.get("tmp"));
rootNode = OBJECT_MAPPER.createObjectNode();
definesNode = OBJECT_MAPPER.createObjectNode();
rootNode.set("defines", definesNode);
process((EClass) ePackage.getEClassifier("IfcShapeRepresentation"), (EClass) ePackage.getEClassifier("IfcRepresentation"));
// cleanup();
try {
Files.write(OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsBytes(rootNode), new File("C:\\Users\\Ruben de Laat\\git\\BIMserver\\BimServer\\src\\org\\bimserver\\database\\queries\\json\\" + schema.name().toLowerCase() + "-geometry.json"));
} catch (JsonProcessingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project vertx-swagger by bobxwang.
the class Application method main.
public static void main(String[] args) throws IOException {
System.setProperty("vertx.logger-delegate-factory-class-name", "io.vertx.core.logging.SLF4JLogDelegateFactory");
System.setProperty("hsqldb.reconfig_logging", "false");
ApplicationContext applicationContext = SwaggerApp.Run(SpringConfig.class);
Application application = new Application();
application.demo(applicationContext);
final ObjectMapper objectMapper = applicationContext.getBean(ObjectMapper.class);
final Router router = applicationContext.getBean(Router.class);
router.route().failureHandler(frc -> {
/**
* 任一请求出错都会进入到这里
*/
int statusCode = frc.statusCode();
HttpServerResponse response = frc.response();
response.putHeader("content-type", "application/json;charset=UTF-8");
Map<String, String> map = new HashMap<>();
map.put("error", "Sorry! Not today");
map.put("status", String.valueOf(statusCode));
map.put("path", frc.request().path());
map.put("msg", frc.failure() == null ? "" : frc.failure().getMessage());
String rs = "{}";
try {
rs = objectMapper.writeValueAsString(map);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
response.setStatusCode(statusCode).end(rs);
});
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project FarmCloud by vratsasg.
the class EmbeddedController method getAllDevicesWateringTime.
@RequestMapping(value = "endDevicesTime", method = RequestMethod.GET)
public ResponseEntity<String> getAllDevicesWateringTime(@RequestParam("identifier") String coordinator) {
String JsonResults = null;
try {
ObjectMapper mapper = new ObjectMapper();
List<EmebddedSetupDevicdeDto> ls = featureofInterestService.findEndDevicesTimes(coordinator);
JsonResults = mapper.writeValueAsString(ls);
} catch (JsonProcessingException e) {
e.printStackTrace();
return new ResponseEntity<String>(e.getMessage(), HttpStatus.BAD_REQUEST);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity<String>(e.getMessage(), HttpStatus.BAD_REQUEST);
}
return new ResponseEntity<String>(JsonResults, HttpStatus.OK);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project FarmCloud by vratsasg.
the class FeatureofInterestServiceImpl method findMinMaxbyUserId.
public String findMinMaxbyUserId(Integer userid) {
String jsonInString = null;
try {
List<FeatureObsPropMinMax> results = featureofinterestJpaRepository.findFeatureMiMaxValuesByUserId(userid);
List<FeatureObsProp> featureobsPropList = new ArrayList<FeatureObsProp>();
featureobsPropList.add(new FeatureObsProp(results.get(0).getFeatureofinterestid(), results.get(0).getIdentifier(), results.get(0).getName()));
for (FeatureObsPropMinMax obj : results) {
boolean newaddition = true;
for (int i = 0; i < featureobsPropList.size(); i++) {
FeatureObsProp feature = featureobsPropList.get(i);
if (obj.getFeatureofinterestid() == feature.getFeatureofinterestid()) {
newaddition = false;
}
}
if (newaddition) {
featureobsPropList.add(new FeatureObsProp(obj.getFeatureofinterestid(), obj.getIdentifier(), obj.getName()));
}
}
for (FeatureObsPropMinMax obj : results) {
for (FeatureObsProp feature : featureobsPropList) {
if (obj.getFeatureofinterestid() == feature.getFeatureofinterestid()) {
feature.getFeatureObsproplist().add(new FeatureMinMaxValue((obj.getObspropvalId()).longValue(), obj.getObspropertName(), obj.getMinval(), obj.getMaxval()));
}
}
}
// Object to JSON in String
ObjectMapper mapper = new ObjectMapper();
jsonInString = mapper.writeValueAsString(featureobsPropList);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return jsonInString;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project apache-kafka-on-k8s by banzaicloud.
the class TransactionalMessageCopier method toJsonString.
private static String toJsonString(Map<String, Object> data) {
String json;
try {
ObjectMapper mapper = new ObjectMapper();
json = mapper.writeValueAsString(data);
} catch (JsonProcessingException e) {
json = "Bad data can't be written as json: " + e.getMessage();
}
return json;
}
Aggregations