@Test public void convert_invalid_acronym() throws IOException { eu.dnetlib.dhp.schema.oaf.Project srcProject = emptyProject(ID); Field<String> acronym = new Field<>(); acronym.setValue(INVALID_ACRONYM); srcProject.setAcronym(acronym); Project project = converter.convert(srcProject); assertNull(project); }
@Override public Project convert(eu.dnetlib.dhp.schema.oaf.Project sourceProject) throws IOException { Preconditions.checkNotNull(sourceProject); Project.Builder builder = Project.newBuilder(); builder.setId(sourceProject.getId()); Field<String> acronym = sourceProject.getAcronym(); if (isAcronymValid(acronym)) { builder.setProjectAcronym(acronym.getValue()); } String projectGrantId = sourceProject.getCode() != null ? sourceProject.getCode().getValue() : null; if (StringUtils.isNotBlank(projectGrantId)) { builder.setProjectGrantId(projectGrantId); } String jsonExtraInfo = sourceProject.getJsonextrainfo() != null ? sourceProject.getJsonextrainfo().getValue() : null; if (StringUtils.isNotBlank(jsonExtraInfo)) { builder.setJsonextrainfo(jsonExtraInfo); } else { builder.setJsonextrainfo(BLANK_JSONEXTRAINFO); } String extractedFundingClass = fundingTreeParser.extractFundingClass( extractStringValues(sourceProject.getFundingtree())); if (StringUtils.isNotBlank(extractedFundingClass)) { builder.setFundingClass(extractedFundingClass); } return isDataValid(builder)?builder.build():null; }
ProjectConverter implements OafEntityToAvroConverter<eu.dnetlib.dhp.schema.oaf.Project, Project> { @Override public Project convert(eu.dnetlib.dhp.schema.oaf.Project sourceProject) throws IOException { Preconditions.checkNotNull(sourceProject); Project.Builder builder = Project.newBuilder(); builder.setId(sourceProject.getId()); Field<String> acronym = sourceProject.getAcronym(); if (isAcronymValid(acronym)) { builder.setProjectAcronym(acronym.getValue()); } String projectGrantId = sourceProject.getCode() != null ? sourceProject.getCode().getValue() : null; if (StringUtils.isNotBlank(projectGrantId)) { builder.setProjectGrantId(projectGrantId); } String jsonExtraInfo = sourceProject.getJsonextrainfo() != null ? sourceProject.getJsonextrainfo().getValue() : null; if (StringUtils.isNotBlank(jsonExtraInfo)) { builder.setJsonextrainfo(jsonExtraInfo); } else { builder.setJsonextrainfo(BLANK_JSONEXTRAINFO); } String extractedFundingClass = fundingTreeParser.extractFundingClass( extractStringValues(sourceProject.getFundingtree())); if (StringUtils.isNotBlank(extractedFundingClass)) { builder.setFundingClass(extractedFundingClass); } return isDataValid(builder)?builder.build():null; } }
ProjectConverter implements OafEntityToAvroConverter<eu.dnetlib.dhp.schema.oaf.Project, Project> { @Override public Project convert(eu.dnetlib.dhp.schema.oaf.Project sourceProject) throws IOException { Preconditions.checkNotNull(sourceProject); Project.Builder builder = Project.newBuilder(); builder.setId(sourceProject.getId()); Field<String> acronym = sourceProject.getAcronym(); if (isAcronymValid(acronym)) { builder.setProjectAcronym(acronym.getValue()); } String projectGrantId = sourceProject.getCode() != null ? sourceProject.getCode().getValue() : null; if (StringUtils.isNotBlank(projectGrantId)) { builder.setProjectGrantId(projectGrantId); } String jsonExtraInfo = sourceProject.getJsonextrainfo() != null ? sourceProject.getJsonextrainfo().getValue() : null; if (StringUtils.isNotBlank(jsonExtraInfo)) { builder.setJsonextrainfo(jsonExtraInfo); } else { builder.setJsonextrainfo(BLANK_JSONEXTRAINFO); } String extractedFundingClass = fundingTreeParser.extractFundingClass( extractStringValues(sourceProject.getFundingtree())); if (StringUtils.isNotBlank(extractedFundingClass)) { builder.setFundingClass(extractedFundingClass); } return isDataValid(builder)?builder.build():null; }  }
ProjectConverter implements OafEntityToAvroConverter<eu.dnetlib.dhp.schema.oaf.Project, Project> { @Override public Project convert(eu.dnetlib.dhp.schema.oaf.Project sourceProject) throws IOException { Preconditions.checkNotNull(sourceProject); Project.Builder builder = Project.newBuilder(); builder.setId(sourceProject.getId()); Field<String> acronym = sourceProject.getAcronym(); if (isAcronymValid(acronym)) { builder.setProjectAcronym(acronym.getValue()); } String projectGrantId = sourceProject.getCode() != null ? sourceProject.getCode().getValue() : null; if (StringUtils.isNotBlank(projectGrantId)) { builder.setProjectGrantId(projectGrantId); } String jsonExtraInfo = sourceProject.getJsonextrainfo() != null ? sourceProject.getJsonextrainfo().getValue() : null; if (StringUtils.isNotBlank(jsonExtraInfo)) { builder.setJsonextrainfo(jsonExtraInfo); } else { builder.setJsonextrainfo(BLANK_JSONEXTRAINFO); } String extractedFundingClass = fundingTreeParser.extractFundingClass( extractStringValues(sourceProject.getFundingtree())); if (StringUtils.isNotBlank(extractedFundingClass)) { builder.setFundingClass(extractedFundingClass); } return isDataValid(builder)?builder.build():null; }  @Override Project convert(eu.dnetlib.dhp.schema.oaf.Project sourceProject); static boolean isAcronymValid(String acronym); boolean isDataValid(Project.Builder builder); }
ProjectConverter implements OafEntityToAvroConverter<eu.dnetlib.dhp.schema.oaf.Project, Project> { @Override public Project convert(eu.dnetlib.dhp.schema.oaf.Project sourceProject) throws IOException { Preconditions.checkNotNull(sourceProject); Project.Builder builder = Project.newBuilder(); builder.setId(sourceProject.getId()); Field<String> acronym = sourceProject.getAcronym(); if (isAcronymValid(acronym)) { builder.setProjectAcronym(acronym.getValue()); } String projectGrantId = sourceProject.getCode() != null ? sourceProject.getCode().getValue() : null; if (StringUtils.isNotBlank(projectGrantId)) { builder.setProjectGrantId(projectGrantId); } String jsonExtraInfo = sourceProject.getJsonextrainfo() != null ? sourceProject.getJsonextrainfo().getValue() : null; if (StringUtils.isNotBlank(jsonExtraInfo)) { builder.setJsonextrainfo(jsonExtraInfo); } else { builder.setJsonextrainfo(BLANK_JSONEXTRAINFO); } String extractedFundingClass = fundingTreeParser.extractFundingClass( extractStringValues(sourceProject.getFundingtree())); if (StringUtils.isNotBlank(extractedFundingClass)) { builder.setFundingClass(extractedFundingClass); } return isDataValid(builder)?builder.build():null; }  @Override Project convert(eu.dnetlib.dhp.schema.oaf.Project sourceProject); static boolean isAcronymValid(String acronym); boolean isDataValid(Project.Builder builder); static final String BLANK_JSONEXTRAINFO; }