use of fi.otavanopisto.muikku.plugins.material.model.MaterialMeta in project muikku by otavanopisto.
the class MaterialMetaRESTService method listMaterialMetas.
@GET
@Path("/materials/{id}/meta/")
@Produces(MediaType.APPLICATION_JSON)
@RESTPermitUnimplemented
public Response listMaterialMetas(@PathParam("id") Long id) {
Material material = materialController.findMaterialById(id);
if (material == null) {
return Response.status(Status.NOT_FOUND).entity("Material not found").build();
}
List<MaterialMeta> metas = materialController.listMaterialMetas(material);
if (metas.isEmpty()) {
return Response.noContent().build();
}
return Response.ok(createRestModel(metas.toArray(new MaterialMeta[0]))).build();
}
use of fi.otavanopisto.muikku.plugins.material.model.MaterialMeta in project muikku by otavanopisto.
the class BinaryMaterialCloneOperation method clone.
@Override
public BinaryMaterial clone(BinaryMaterial material) {
BinaryMaterial clonedMaterial = binaryMaterialController.createBinaryMaterial(material.getTitle(), material.getContentType(), material.getContent(), material, material.getLicense(), material.getViewRestrict());
List<MaterialMeta> materialMetas = materialController.listMaterialMetas(material);
for (MaterialMeta materialMeta : materialMetas) {
materialController.createMaterialMeta(clonedMaterial, materialMeta.getKey(), materialMeta.getValue());
}
List<MaterialProducer> materialProducers = materialController.listMaterialProducers(material);
for (MaterialProducer materialProducer : materialProducers) {
materialController.createMaterialProducer(clonedMaterial, materialProducer.getName());
}
return clonedMaterial;
}
use of fi.otavanopisto.muikku.plugins.material.model.MaterialMeta in project muikku by otavanopisto.
the class HtmlMaterialCloneOperation method clone.
@Override
public HtmlMaterial clone(HtmlMaterial material) {
HtmlMaterial clonedMaterial = htmlMaterialController.createHtmlMaterial(material.getTitle(), material.getHtml(), material.getContentType(), new Long(0), material, material.getLicense(), material.getViewRestrict());
List<MaterialMeta> materialMetas = materialController.listMaterialMetas(material);
for (MaterialMeta materialMeta : materialMetas) {
materialController.createMaterialMeta(clonedMaterial, materialMeta.getKey(), materialMeta.getValue());
}
List<MaterialProducer> materialProducers = materialController.listMaterialProducers(material);
for (MaterialProducer materialProducer : materialProducers) {
materialController.createMaterialProducer(clonedMaterial, materialProducer.getName());
}
return clonedMaterial;
}
use of fi.otavanopisto.muikku.plugins.material.model.MaterialMeta in project muikku by otavanopisto.
the class MaterialMetaDAO method create.
public MaterialMeta create(Material material, MaterialMetaKey key, String value) {
MaterialMeta materialMeta = new MaterialMeta();
materialMeta.setKey(key);
materialMeta.setMaterial(material);
materialMeta.setValue(value);
return persist(materialMeta);
}
use of fi.otavanopisto.muikku.plugins.material.model.MaterialMeta in project muikku by otavanopisto.
the class MaterialMetaDAO method listByMaterial.
public List<MaterialMeta> listByMaterial(Material material) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<MaterialMeta> criteria = criteriaBuilder.createQuery(MaterialMeta.class);
Root<MaterialMeta> root = criteria.from(MaterialMeta.class);
criteria.select(root);
criteria.where(criteriaBuilder.equal(root.get(MaterialMeta_.material), material));
return entityManager.createQuery(criteria).getResultList();
}
Aggregations