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

switch com.peregrine.models.ObjectModel to use json-schema.json instead of dialog.json #852

Open
reusr1 opened this issue Apr 9, 2021 · 1 comment
Assignees

Comments

@reusr1
Copy link
Contributor

reusr1 commented Apr 9, 2021

we should try to see if we can use the https://www.jsonschema2pojo.org/ library to dynamically generate the sling models from the json schema

@reusr1
Copy link
Contributor Author

reusr1 commented Apr 9, 2021

base of the code that should change

Resource definitionDialog = source.getResourceResolver().getResource(objectDefinitionPath + SLASH + DIALOG_JSON);
if(definitionDialog != null) {
InputStream is = definitionDialog.adaptTo(InputStream.class);
if(is != null) {
String dialog = null;
try {
dialog = ServletHelper.asString(is).toString();
ObjectMapper mapper = new ObjectMapper();
DialogBean dialogBean = mapper.readValue(dialog, DialogBean.class);
for(GroupItem group: dialogBean.getGroups()) {
for (FieldItem field : group.getFields()) {
answer.put(field.getModel(), properties.get(field.getModel(), String.class));
}
}
for (FieldItem field : dialogBean.getFields()) {
answer.put(field.getModel(), properties.get(field.getModel(), String.class));
}
} catch (IOException e) {
if(dialog == null) {
logger.warn("Dialog Resource count not be read as input stream: '{}'", objectDefinitionPath + SLASH + DIALOG_JSON);
} else {
logger.warn("Failed to parse given Dialog content into Dialog Bean: '{}'", dialog);
}
}
}

flx-sta added a commit that referenced this issue Apr 26, 2021
…nitions

Issues/852 json schemas for object definitions
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

2 participants