use of fi.otavanopisto.muikku.plugins.material.model.QueryField in project muikku by otavanopisto.
the class QueryFieldChangeListener method onQueryOrganizerFieldUpdate.
public void onQueryOrganizerFieldUpdate(@Observes QueryFieldUpdateEvent event) {
if (event.getMaterialField().getType().equals("application/vnd.muikku.field.organizer")) {
QueryField queryField = event.getQueryField();
List<WorkspaceMaterialField> workspaceMaterialFields = workspaceMaterialFieldController.listWorkspaceMaterialFieldsByQueryField(queryField);
for (WorkspaceMaterialField workspaceMaterialField : workspaceMaterialFields) {
workspaceMaterialFieldController.updateWorkspaceMaterialField(workspaceMaterialField, event.getMaterialField(), event.getRemoveAnswers());
}
}
}
use of fi.otavanopisto.muikku.plugins.material.model.QueryField in project muikku by otavanopisto.
the class QueryFieldChangeListener method onQuerySorterFieldUpdate.
public void onQuerySorterFieldUpdate(@Observes QueryFieldUpdateEvent event) {
if (event.getMaterialField().getType().equals("application/vnd.muikku.field.sorter")) {
QueryField queryField = event.getQueryField();
List<WorkspaceMaterialField> workspaceMaterialFields = workspaceMaterialFieldController.listWorkspaceMaterialFieldsByQueryField(queryField);
for (WorkspaceMaterialField workspaceMaterialField : workspaceMaterialFields) {
workspaceMaterialFieldController.updateWorkspaceMaterialField(workspaceMaterialField, event.getMaterialField(), event.getRemoveAnswers());
}
}
}
use of fi.otavanopisto.muikku.plugins.material.model.QueryField in project muikku by otavanopisto.
the class QueryFieldChangeListener method onQuerySelectFieldUpdate.
public void onQuerySelectFieldUpdate(@Observes QueryFieldUpdateEvent event) {
if (event.getMaterialField().getType().equals("application/vnd.muikku.field.select")) {
QueryField queryField = event.getQueryField();
List<WorkspaceMaterialField> workspaceMaterialFields = workspaceMaterialFieldController.listWorkspaceMaterialFieldsByQueryField(queryField);
for (WorkspaceMaterialField workspaceMaterialField : workspaceMaterialFields) {
workspaceMaterialFieldController.updateWorkspaceMaterialField(workspaceMaterialField, event.getMaterialField(), event.getRemoveAnswers());
}
}
}
use of fi.otavanopisto.muikku.plugins.material.model.QueryField in project muikku by otavanopisto.
the class HtmlMaterialFieldChangeListener method onHtmlMaterialAudioFieldCreated.
// Audio field
public void onHtmlMaterialAudioFieldCreated(@Observes HtmlMaterialFieldCreateEvent event) throws MaterialQueryIntegrityExeption, MaterialFieldMetaParsingExeption {
if (event.getField().getType().equals("application/vnd.muikku.field.audio")) {
ObjectMapper objectMapper = new ObjectMapper();
AudioFieldMeta audioFieldMeta;
try {
audioFieldMeta = objectMapper.readValue(event.getField().getContent(), AudioFieldMeta.class);
} catch (IOException e) {
throw new MaterialFieldMetaParsingExeption("Could not parse audio field meta", e);
}
QueryField queryField = queryFieldController.findQueryFieldByMaterialAndName(event.getMaterial(), audioFieldMeta.getName());
if (queryField != null) {
throw new MaterialQueryIntegrityExeption("Field with same name already exists in the database");
}
queryAudioFieldController.createQueryAudioField(event.getMaterial(), audioFieldMeta.getName());
}
}
use of fi.otavanopisto.muikku.plugins.material.model.QueryField in project muikku by otavanopisto.
the class HtmlMaterialFieldChangeListener method onHtmlMaterialConnectFieldCreated.
// Connect field
public void onHtmlMaterialConnectFieldCreated(@Observes HtmlMaterialFieldCreateEvent event) throws MaterialQueryIntegrityExeption, MaterialFieldMetaParsingExeption {
if (event.getField().getType().equals("application/vnd.muikku.field.connect")) {
ObjectMapper objectMapper = new ObjectMapper();
ConnectFieldMeta connectFieldMeta;
try {
connectFieldMeta = objectMapper.readValue(event.getField().getContent(), ConnectFieldMeta.class);
} catch (IOException e) {
throw new MaterialFieldMetaParsingExeption("Could not parse connect field meta", e);
}
QueryField queryField = queryFieldController.findQueryFieldByMaterialAndName(event.getMaterial(), connectFieldMeta.getName());
if (queryField != null) {
throw new MaterialQueryIntegrityExeption("Field with same name already exists in the database");
}
QueryConnectField field = queryConnectFieldController.createQueryConnectField(event.getMaterial(), connectFieldMeta.getName());
Map<String, QueryConnectFieldTerm> terms = new HashMap<String, QueryConnectFieldTerm>();
Map<String, QueryConnectFieldCounterpart> counterparts = new HashMap<String, QueryConnectFieldCounterpart>();
for (ConnectFieldOptionMeta option : connectFieldMeta.getFields()) {
terms.put(option.getName(), queryConnectFieldController.createConnectFieldTerm(field, option.getName(), option.getText(), null));
}
for (ConnectFieldOptionMeta option : connectFieldMeta.getCounterparts()) {
counterparts.put(option.getName(), queryConnectFieldController.createConnectFieldCounterpart(field, option.getName(), option.getText()));
}
for (ConnectFieldConnectionMeta connection : connectFieldMeta.getConnections()) {
terms.get(connection.getField()).setCounterpart(counterparts.get(connection.getCounterpart()));
}
}
}
Aggregations