public Entity createProductEntity(final ParsedProduct product) {
    Entity productEntity =
        dataDefinitionService
            .get(SfcSimpleConstants.PLUGIN_IDENTIFIER, SfcSimpleConstants.MODEL_IMPORTED_PRODUCT)
            .create();

    switch (EppParser.ProductType.valueOf(product.getField(FIELD_TYPE))) {
      case ARTICLE:
        productEntity.setField(FIELD_TYPE, "01article");
        break;
      case SERVICE:
        productEntity.setField(FIELD_TYPE, "02service");
        break;
      case PACK:
        productEntity.setField(FIELD_TYPE, "03pack");
        break;
      case SET:
        productEntity.setField(FIELD_TYPE, "04set");
        break;
      default:
        throw new IllegalStateException("unknown product type");
    }
    productEntity.setField(FIELD_IDENTIFICATION_CODE, product.getIdentificationCode());
    productEntity.setField("ean", product.getField("ean"));
    productEntity.setField(FIELD_NAME, product.getField(FIELD_NAME));
    productEntity.setField("description", product.getField("description"));
    productEntity.setField(FIELD_UNIT, product.getField(FIELD_UNIT));
    productEntity.setField(FIELD_CONVERTED, 0);
    return productEntity;
  }
 public Entity getExistingProduct(final ParsedProduct productEntity) {
   SearchCriteriaBuilder productBuilder =
       dataDefinitionService
           .get(SfcSimpleConstants.PLUGIN_IDENTIFIER, SfcSimpleConstants.MODEL_IMPORTED_PRODUCT)
           .find()
           .add(
               SearchRestrictions.eq(
                   FIELD_IDENTIFICATION_CODE, productEntity.getIdentificationCode()))
           .setMaxResults(1);
   SearchResult existingProducts = productBuilder.list();
   if (existingProducts.getTotalNumberOfEntities() > 0) {
     return existingProducts.getEntities().get(0);
   }
   return null;
 }