<commit_before>package it.feio.android.springpadimporter;

import it.feio.android.springpadimporter.models.SpringpadAttachment;
import it.feio.android.springpadimporter.models.SpringpadElement;
import it.feio.android.springpadimporter.utils.Constants;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
import listeners.ZipProgressesListener;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.progress.ProgressMonitor;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.filefilter.TrueFileFilter;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import exceptions.ImportException;

public class Importer {

	private final static String JSON = "export.json";

	private List<SpringpadElement> list;
	private String outputTemporaryFolder;
	private String workingPath;
	private Integer notesCount, notebooksCount;
	private ZipProgressesListener mZipProgressesListener;

	private ProgressMonitor pm;


	public static void main(String[] args) {
		Importer importer = new Importer();
		importer.setZipProgressesListener(new ZipProgressesListener() {			
			public void onZipProgress(int progressPercentage) {
				System.out.println(progressPercentage);
			}
		});
		try {
			importer.doImport("/home/fede/Scaricati/federico.iosue-export(last).zip");
		} catch (ImportException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		List<SpringpadElement> list = importer.getSpringpadNotes();
		for (SpringpadElement springpadNote : list) {
			if (springpadNote.getImage() != null || springpadNote.getAttachments().size() > 0) {
				System.out.println("\n");
			}
			springpadNote.toString();
			if (springpadNote.getImage() != null) {
				System.out.println("Image: " + importer.getWorkingPath() + springpadNote.getImage());
			}
			for (SpringpadAttachment springpadAttachment : springpadNote.getAttachments()) {
				if (springpadAttachment.getUrl().equals(springpadAttachment.getImage())) {
					System.out.println("Image again!: " + importer.getWorkingPath() + springpadAttachment.getUrl());
				} else {
					System.out.println("Attachment: " + importer.getWorkingPath() + springpadAttachment.getUrl());
				}
			}
		}
		try {
			importer.clean();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	public void setZipProgressesListener(ZipProgressesListener listener) {
		this.mZipProgressesListener = listener;
	}


	public void doImport(String zipExport) throws ImportException {
		File json;
		try {
			json = getJson(zipExport);
			this.list = parseJson(json);
		} catch (ImportException e) {
			throw e;<commit_msg>Just some testing modifications. Should be moved to jUnits<commit_after>package it.feio.android.springpadimporter;

import it.feio.android.springpadimporter.models.SpringpadComment;
import it.feio.android.springpadimporter.models.SpringpadElement;
import it.feio.android.springpadimporter.utils.Constants;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
import listeners.ZipProgressesListener;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.progress.ProgressMonitor;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.filefilter.TrueFileFilter;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import exceptions.ImportException;

public class Importer {

	private final static String JSON = "export.json";

	private List<SpringpadElement> list;
	private String outputTemporaryFolder;
	private String workingPath;
	private Integer notesCount, notebooksCount;
	private ZipProgressesListener mZipProgressesListener;

	private ProgressMonitor pm;


	public static void main(String[] args) {
		Importer importer = new Importer();
		importer.setZipProgressesListener(new ZipProgressesListener() {			
			public void onZipProgress(int progressPercentage) {
				System.out.println(progressPercentage);
			}
		});
		try {
//			importer.doImport("/home/fede/Scaricati/federico.iosue-export(last).zip");
//			importer.doImport("/home/fede/Scaricati/Tfdm-export (1).zip");
			importer.doImport("/home/fede/Scaricati/My_Springpad_Export.zip");
			
		} catch (ImportException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		for (SpringpadElement springpadElement : importer.getNotes()) {

			StringBuilder content = new StringBuilder();

			if (springpadElement.getType() == null) {
				continue;
			}
			
			if (springpadElement.getType().equals(SpringpadElement.TYPE_VIDEO)) {
				try {
					content.append(System.getProperty("line.separator")).append(springpadElement.getVideos().get(0));
				} catch (IndexOutOfBoundsException e ) {
					content.append(System.getProperty("line.separator")).append(springpadElement.getUrl());
				}
			}
			if (springpadElement.getType().equals(SpringpadElement.TYPE_TVSHOW)) {
				content.append(System.getProperty("line.separator")).append(springpadElement.getCast());
			}
			if (springpadElement.getType().equals(SpringpadElement.TYPE_BOOK)) {
				content.append(System.getProperty("line.separator")).append("Author: ")
						.append(springpadElement.getAuthor()).append(System.getProperty("line.separator"))
						.append("Publication date: ").append(springpadElement.getPublicationDate());
			}
			if (springpadElement.getType().equals(SpringpadElement.TYPE_RECIPE)) {
				content.append(System.getProperty("line.separator")).append("Ingredients: ")
						.append(springpadElement.getIngredients()).append(System.getProperty("line.separator"))
						.append("Directions: ").append(springpadElement.getDirections());
			}
			if (springpadElement.getType().equals(SpringpadElement.TYPE_BOOKMARK)) {
				content.append(System.getProperty("line.separator")).append(springpadElement.getUrl());
			}
			if (springpadElement.getType().equals(SpringpadElement.TYPE_BUSINESS)
					&& springpadElement.getPhoneNumbers() != null) {
				content.append(System.getProperty("line.separator")).append("Phone number: ")
						.append(springpadElement.getPhoneNumbers().getPhone());
			}
			if (springpadElement.getType().equals(SpringpadElement.TYPE_PRODUCT)) {
				content.append(System.getProperty("line.separator")).append("Category: ")
						.append(springpadElement.getCategory()).append(System.getProperty("line.separator"))
						.append("Manufacturer: ").append(springpadElement.getManufacturer())
						.append(System.getProperty("line.separator")).append("Price: ")
						.append(springpadElement.getPrice());
			}
			if (springpadElement.getType().equals(SpringpadElement.TYPE_WINE)) {
				content.append(System.getProperty("line.separator")).append("Wine type: ")
						.append(springpadElement.getWine_type()).append(System.getProperty("line.separator"))
						.append("Varietal: ").append(springpadElement.getVarietal())
						.append(System.getProperty("line.separator")).append("Price: ")
						.append(springpadElement.getPrice());
			}
			if (springpadElement.getType().equals(SpringpadElement.TYPE_ALBUM)) {
				content.append(System.getProperty("line.separator")).append("Artist: ")
						.append(springpadElement.getArtist());
			}
			for (SpringpadComment springpadComment : springpadElement.getComments()) {
				content.append(System.getProperty("line.separator")).append(springpadComment.getCommenter())
						.append(" commented at 0").append(springpadComment.getDate()).append(": ")
						.append(springpadElement.getArtist());
			}

			System.out.println(content);

		}
		try {
			importer.clean();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	public void setZipProgressesListener(ZipProgressesListener listener) {
		this.mZipProgressesListener = listener;
	}


	public void doImport(String zipExport) throws ImportException {
		File json;
		try {
			json = getJson(zipExport);
			this.list = parseJson(json);
		} catch (ImportException e) {
			throw e;
{'fraction_non_alphanumeric': 0.1291065583707116, 'fraction_numerical': 0.0009698145229724816, 'mean_word_length': 5.075110456553755, 'pattern_counts': {'":': 1, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5525975', 'n_tokens_mistral': 2816, 'n_tokens_neox': 2459, 'n_words': 378}