<commit_before>package jobs;
import java.io.File;
import java.util.LinkedList;
import java.util.List;

import controllers.ImageBrowser;

import access.AccessType;

import play.*;
import play.jobs.*;
import play.test.*;
import services.PathService;
import services.PermissionService;
 
import models.*;
 
@OnApplicationStart
public class Bootstrap extends Job {
    public void doJob() {
        if(Project.count() == 0) {
	        Fixtures.deleteDatabase();
	        
	        new Podbase().save();
	        
	        User root = new User("root","lucifer");
	        root.special = true;
	        root.save();
	        
	        User guest = new User("guest",null);
	        guest.special = true;
	        guest.save();
	        
	        User authenticated = new User("authenticated",null);
	        authenticated.special = true;
	        authenticated.save();
	        
	        User a = new User("<EMAIL>", "secret").save();
	        User b = new User("<EMAIL>", "secret").save();
	        User c = new User("<EMAIL>", "lucifer").save();
	        
	        //Guest user permissions
	        new Permission(a,null,AccessType.CREATE_PROJECT).save();
	        new Permission(a,null,AccessType.CREATE_PAPER).save();
	        
	        List<User> users = new LinkedList<User>();
	        users.add(a);
	        users.add(b);
	        users.add(c);
	        
	        for (File f : PathService.getRootImageDirectory().toFile().listFiles()) {
	        	if (f.isDirectory()) {
		        	System.out.println("Creating project: "+f.getName());
			        Project project = new Project(f.getName()).save();
			        
			        new Permission(c,project,AccessType.OWNER).save();
			        new Permission(authenticated,project,AccessType.VISIBLE).save();
			        new Permission(authenticated,project,AccessType.LISTED).save();
			        
			        Template template = new Template(project, f.getName()+"_demo_template").save();
			        template.addAttribute("Image Name","The name of the image");
			        template.addAttribute("Species","The species of the animal");
			        template.addAttribute("Magnification","The magnification that this image was taken at");
			        
			        addUsersToProject(project, users);
			        
		        	project.addDirectory("/"+f.getName());
	        	}
	        }
	        
	        Project sandbox = Project.find("byName", "GuestSandbox").first();
	        PermissionService.addPermission(guest, sandbox, AccessType.OWNER);
	        PermissionService.addPermission(guest, sandbox, AccessType.LISTED);
	        PermissionService.addPermission(guest, sandbox, AccessType.VISIBLE);
	        PermissionService.addPermission(guest, sandbox, AccessType.EDITOR);
	        
	        Project pub = Project.find("byName", "Public").first();
	        PermissionService.addPermission(guest, pub, AccessType.LISTED);
	        PermissionService.addPermission(guest, pub, AccessType.VISIBLE);
    	}
    }<commit_msg>making sandbox and public project optional<commit_after>package jobs;
import java.io.File;
import java.util.LinkedList;
import java.util.List;

import controllers.ImageBrowser;

import access.AccessType;

import play.*;
import play.jobs.*;
import play.test.*;
import services.PathService;
import services.PermissionService;
 
import models.*;
 
@OnApplicationStart
public class Bootstrap extends Job {
    public void doJob() {
        if(Project.count() == 0) {
	        Fixtures.deleteDatabase();
	        
	        new Podbase().save();
	        
	        User root = new User("root","lucifer");
	        root.special = true;
	        root.save();
	        
	        User guest = new User("guest",null);
	        guest.special = true;
	        guest.save();
	        
	        User authenticated = new User("authenticated",null);
	        authenticated.special = true;
	        authenticated.save();
	        
	        User a = new User("<EMAIL>", "secret").save();
	        User b = new User("<EMAIL>", "secret").save();
	        User c = new User("<EMAIL>", "lucifer").save();
	        
	        //Guest user permissions
	        new Permission(a,null,AccessType.CREATE_PROJECT).save();
	        new Permission(a,null,AccessType.CREATE_PAPER).save();
	        
	        List<User> users = new LinkedList<User>();
	        users.add(a);
	        users.add(b);
	        users.add(c);
	        
	        for (File f : PathService.getRootImageDirectory().toFile().listFiles()) {
	        	if (f.isDirectory()) {
		        	System.out.println("Creating project: "+f.getName());
			        Project project = new Project(f.getName()).save();
			        
			        new Permission(c,project,AccessType.OWNER).save();
			        new Permission(authenticated,project,AccessType.VISIBLE).save();
			        new Permission(authenticated,project,AccessType.LISTED).save();
			        
			        Template template = new Template(project, f.getName()+"_demo_template").save();
			        template.addAttribute("Image Name","The name of the image");
			        template.addAttribute("Species","The species of the animal");
			        template.addAttribute("Magnification","The magnification that this image was taken at");
			        
			        addUsersToProject(project, users);
			        
		        	project.addDirectory("/"+f.getName());
	        	}
	        }
	        
	        Project sandbox = Project.find("byName", "GuestSandbox").first();
	        if (sandbox != null) {
		        PermissionService.addPermission(guest, sandbox, AccessType.OWNER);
		        PermissionService.addPermission(guest, sandbox, AccessType.LISTED);
		        PermissionService.addPermission(guest, sandbox, AccessType.VISIBLE);
		        PermissionService.addPermission(guest, sandbox, AccessType.EDITOR);
	        } else {
	        	System.out.println("Sandbox project not found!");
	        }
	        
	        Project pub = Project.find("byName", "Public").first();
	        if (pub != null) {
		        PermissionService.addPermission(guest, pub, AccessType.LISTED);
		        PermissionService.addPermission(guest, pub, AccessType.VISIBLE);
	        } else {
	        	System.out.println("Public project not found!");
	        }
    	}
    }
{'fraction_non_alphanumeric': 0.12815533980582525, 'fraction_numerical': 0.00032362459546925567, 'mean_word_length': 2.3812910284463893, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '5250362', 'n_tokens_mistral': 1859, 'n_tokens_neox': 1603, 'n_words': 341}