use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class Lwm2mObjectIdResolverTest method testResolveForExistingObjectId.
@Test
public void testResolveForExistingObjectId() {
importModel("lwm2m/ColorLight.fbmodel");
importModel("lwm2m/ColorLight_lwm2m.mapping");
DefaultResolver lwm2mResolver = new DefaultResolver();
lwm2mResolver.setRepositoryFactory(repositoryFactory);
lwm2mResolver.setSearchService(searchService);
assertEquals(new ModelId("ColorLight", "com.mycompany.fb", "1.0.0"), lwm2mResolver.resolve(new LWM2MQuery("2")));
assertNotNull(repositoryFactory.getRepository(createUserContext("admin")).getById(lwm2mResolver.resolve(new LWM2MQuery("2"))));
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class BulkApproveFunction method execute.
@Override
public void execute(ModelInfo model, IUserContext user, Map<String, Object> context) {
for (ModelId referenceId : model.getReferences()) {
IModelRepository repository = repositoryFactory.getRepositoryByModel(referenceId);
ModelInfo referenceModel = repository.getById(referenceId);
if (ModelState.InReview.getName().equals(referenceModel.getState())) {
try {
workflowService.doAction(referenceId, user, SimpleWorkflowModel.ACTION_APPROVE.getName());
} catch (WorkflowException e) {
logger.error("Problem executing release for model " + referenceId + "during bulk approve function", e);
}
}
}
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRepositoryAttachmentTest method testDeleteAttachments.
@Test
public void testDeleteAttachments() throws Exception {
IUserContext erle = createUserContext("erle", "playground");
importModel("Color.type", erle);
ModelId modelId = new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0");
repositoryFactory.getRepository(erle).attachFile(modelId, new FileContent("backup1.xml", IOUtils.toByteArray(new ClassPathResource("sample_models/backup1.xml").getInputStream())), erle);
boolean deleteResult = repositoryFactory.getRepository(erle).deleteAttachment(modelId, "backup1.xml");
assertTrue(deleteResult);
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRepositoryAttachmentTest method testOverwriteAttachmentWithoutTags.
@Test
public void testOverwriteAttachmentWithoutTags() {
IUserContext erle = createUserContext("erle", "playground");
importModel("Color.type", erle);
try {
repositoryFactory.getRepository(erle).attachFile(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"), new FileContent("backup1.xml", IOUtils.toByteArray(new ClassPathResource("sample_models/backup1.xml").getInputStream())), erle);
repositoryFactory.getRepository(erle).attachFile(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"), new FileContent("backup1.xml", IOUtils.toByteArray(new ClassPathResource("sample_models/backup-withImages.xml").getInputStream())), erle);
List<Attachment> attachments = repositoryFactory.getRepository(erle).getAttachments(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"));
assertEquals(1, attachments.size());
assertEquals("backup1.xml", attachments.get(0).getFilename());
assertEquals(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"), attachments.get(0).getModelId());
assertEquals(0, attachments.get(0).getTags().size());
attachments.forEach(attachment -> System.out.println(attachment));
} catch (IOException | FatalModelRepositoryException e) {
e.printStackTrace();
fail("Cannot load sample file");
}
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRepositoryAttachmentTest method testOverwriteImageWithDiffernentTag.
@Test
public void testOverwriteImageWithDiffernentTag() {
IUserContext erle = createUserContext("erle", "playground");
importModel("Color.type", erle);
try {
repositoryFactory.getRepository(erle).attachFile(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"), new FileContent("sample.png", IOUtils.toByteArray(new ClassPathResource("sample_models/sample.png").getInputStream())), erle, Attachment.TAG_IMAGE);
repositoryFactory.getRepository(erle).attachFile(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"), new FileContent("sample.png", IOUtils.toByteArray(new ClassPathResource("sample_models/sample.png").getInputStream())), erle, Attachment.TAG_DOCUMENTATION);
List<Attachment> attachments = repositoryFactory.getRepository(erle).getAttachments(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"));
assertEquals(1, attachments.size());
assertEquals("sample.png", attachments.get(0).getFilename());
assertEquals(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"), attachments.get(0).getModelId());
assertEquals(1, attachments.get(0).getTags().size());
assertEquals("Documentation", attachments.get(0).getTags().get(0).getLabel());
} catch (IOException | FatalModelRepositoryException e) {
e.printStackTrace();
fail("Cannot load sample file");
}
}
Aggregations