@Test public void testDirectMapping() { NeutralRecord directlyMapped = new NeutralRecord(); directlyMapped.setRecordType("directEntity"); directlyMapped.setAttributeField("field2", "Test String"); ReportStats reportStats = new SimpleReportStats(); List<? extends Entity> result = transformer.transform(directlyMapped, new DummyMessageReport(), reportStats); Assert.assertNotNull(result); Assert.assertEquals(1, result.size()); Assert.assertEquals("Test String", result.get(0).getBody().get("field1")); }
@Override public List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats) { JavaResult result = new JavaResult(); Smooks smooks = smooksConfigs.get(item.getRecordType()); if (smooks == null) { String type = item.getRecordType().replaceAll("_transformed", ""); Map<String, Object> body = item.getAttributes(); SimpleEntity entity = new SimpleEntity(); entity.setType(type); entity.setBody(body); entity.setStagedEntityId(item.getRecordId()); entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } String externalId = (String) item.getLocalId(); if (externalId != null) { entity.getMetaData().put("externalId", externalId); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); return Arrays.asList(entity); } List<SimpleEntity> sliEntities; try { StringSource source = new StringSource(MAPPER.writeValueAsString(item)); smooks.filterSource(source, result); sliEntities = getEntityListResult(result); for (SimpleEntity entity : sliEntities) { entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); } } catch (java.io.IOException e) { sliEntities = Collections.emptyList(); } return sliEntities; }
SmooksEdFi2SLITransformer extends EdFi2SLITransformer { @Override public List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats) { JavaResult result = new JavaResult(); Smooks smooks = smooksConfigs.get(item.getRecordType()); if (smooks == null) { String type = item.getRecordType().replaceAll("_transformed", ""); Map<String, Object> body = item.getAttributes(); SimpleEntity entity = new SimpleEntity(); entity.setType(type); entity.setBody(body); entity.setStagedEntityId(item.getRecordId()); entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } String externalId = (String) item.getLocalId(); if (externalId != null) { entity.getMetaData().put("externalId", externalId); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); return Arrays.asList(entity); } List<SimpleEntity> sliEntities; try { StringSource source = new StringSource(MAPPER.writeValueAsString(item)); smooks.filterSource(source, result); sliEntities = getEntityListResult(result); for (SimpleEntity entity : sliEntities) { entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); } } catch (java.io.IOException e) { sliEntities = Collections.emptyList(); } return sliEntities; } }
SmooksEdFi2SLITransformer extends EdFi2SLITransformer { @Override public List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats) { JavaResult result = new JavaResult(); Smooks smooks = smooksConfigs.get(item.getRecordType()); if (smooks == null) { String type = item.getRecordType().replaceAll("_transformed", ""); Map<String, Object> body = item.getAttributes(); SimpleEntity entity = new SimpleEntity(); entity.setType(type); entity.setBody(body); entity.setStagedEntityId(item.getRecordId()); entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } String externalId = (String) item.getLocalId(); if (externalId != null) { entity.getMetaData().put("externalId", externalId); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); return Arrays.asList(entity); } List<SimpleEntity> sliEntities; try { StringSource source = new StringSource(MAPPER.writeValueAsString(item)); smooks.filterSource(source, result); sliEntities = getEntityListResult(result); for (SimpleEntity entity : sliEntities) { entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); } } catch (java.io.IOException e) { sliEntities = Collections.emptyList(); } return sliEntities; }  }
SmooksEdFi2SLITransformer extends EdFi2SLITransformer { @Override public List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats) { JavaResult result = new JavaResult(); Smooks smooks = smooksConfigs.get(item.getRecordType()); if (smooks == null) { String type = item.getRecordType().replaceAll("_transformed", ""); Map<String, Object> body = item.getAttributes(); SimpleEntity entity = new SimpleEntity(); entity.setType(type); entity.setBody(body); entity.setStagedEntityId(item.getRecordId()); entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } String externalId = (String) item.getLocalId(); if (externalId != null) { entity.getMetaData().put("externalId", externalId); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); return Arrays.asList(entity); } List<SimpleEntity> sliEntities; try { StringSource source = new StringSource(MAPPER.writeValueAsString(item)); smooks.filterSource(source, result); sliEntities = getEntityListResult(result); for (SimpleEntity entity : sliEntities) { entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); } } catch (java.io.IOException e) { sliEntities = Collections.emptyList(); } return sliEntities; }  @Override List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats); Map<String, Smooks> getSmooksConfigs(); void setSmooksConfigs(Map<String, Smooks> smooksConfigs); @Override List<List<SimpleEntity>> handle(List<NeutralRecord> items, AbstractMessageReport report,
            ReportStats reportStats); @Override String getStageName(); }
SmooksEdFi2SLITransformer extends EdFi2SLITransformer { @Override public List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats) { JavaResult result = new JavaResult(); Smooks smooks = smooksConfigs.get(item.getRecordType()); if (smooks == null) { String type = item.getRecordType().replaceAll("_transformed", ""); Map<String, Object> body = item.getAttributes(); SimpleEntity entity = new SimpleEntity(); entity.setType(type); entity.setBody(body); entity.setStagedEntityId(item.getRecordId()); entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } String externalId = (String) item.getLocalId(); if (externalId != null) { entity.getMetaData().put("externalId", externalId); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); return Arrays.asList(entity); } List<SimpleEntity> sliEntities; try { StringSource source = new StringSource(MAPPER.writeValueAsString(item)); smooks.filterSource(source, result); sliEntities = getEntityListResult(result); for (SimpleEntity entity : sliEntities) { entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); } } catch (java.io.IOException e) { sliEntities = Collections.emptyList(); } return sliEntities; }  @Override List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats); Map<String, Smooks> getSmooksConfigs(); void setSmooksConfigs(Map<String, Smooks> smooksConfigs); @Override List<List<SimpleEntity>> handle(List<NeutralRecord> items, AbstractMessageReport report,
            ReportStats reportStats); @Override String getStageName();  }