public  void insertPicture(FileObject f){
		if(findById(f.getFilePath())==null){
			Album album = new Album();
			if(f.getFilePath() != null || (!(f.getFilePath().equals("")))){
				String albumName ="";
				try{
					albumName= f.getAlbumName().toLowerCase();
					String s =f.getAlbumName().charAt(0) + "";
					albumName  = s.toUpperCase() + albumName.substring(1);
				}catch(Exception u){
					Log.getLogger().log(Level.SEVERE, "Unexpected problems with the String " + f.getAlbumName());
				}
				if(!(albumName.equals(""))){

					album = albumDao.findById(albumName);
					if(album != null){
						beginTransaction();
						try{
							if(album.getCoverPath().equals("")|| album.getCoverPath()==null)
								album.setCoverPath(f.getFilePath());
						}catch(Exception o){	
							Log.getLogger().log(Level.INFO, "Couldn't get coverpath from Album " + album );
							album.setCoverPath(f.getFilePath());
						}
						commitTransaction();
					}else{
						beginTransaction();
						album = new Album();	
						album.setAlbumName(albumName);
						album.setCoverPath(f.getFilePath());
						entityManager.persist(album);
						commitTransaction();
					}
				}
			}
			Picture picture = new Picture();
			String date  = "";
			String fileName = "";
			try{
				date = f.getDate().toLowerCase();
				String s = f.getDate().charAt(0) + "";
				date  = s.toUpperCase() + date.substring(1);
			}catch(Exception u){
				Log.getLogger().log(Level.SEVERE, "Unexpected problems with the String " +f.getDate());
			}
			try{
				fileName = f.getFileName().toLowerCase();
				String s = f.getFileName().charAt(0) + "";
				fileName = s.toUpperCase() + fileName.substring(1);
			}catch(Exception u){
				Log.getLogger().log(Level.SEVERE, "Unexpected problems with the String " + f.getFileName());
			}

			picture = findById(f.getFilePath());
			if(picture != null){
				beginTransaction();
				if(!(f.getDate().equals("")))
					picture.setDate(date);
				if(picture.getName().equals(""))
					picture.setName(fileName);
				List<PictureI> thePictures = new ArrayList<PictureI>();
				thePictures.addAll(album.getPictures());
				if(!(thePictures.contains(picture)))
					thePictures.add(picture);
				album.setPictures(thePictures);
				commitTransaction();
			}else{
				if(entityManager.getTransaction().isActive())
					entityManager.getTransaction().commit();
				beginTransaction();
				picture = new Picture();
				picture.setPath(f.getFilePath());	
				picture.setDate(date);
				if(f.getFileName() != null ||(!f.getFileName().equals(""))){
					picture.setName(fileName);
					picture.setAlbum(album);
					List<PictureI> thePictures = new ArrayList<PictureI>();
					try{
						thePictures.addAll(album.getPictures());
					}catch(Exception p){
						Log.getLogger().log(Level.INFO, "Couldn't get list of PictureIs from Album " + album );
					}
					thePictures.add(picture);

					if(album != null)
						album.setPictures(thePictures);
					entityManager.persist(picture);
					commitTransaction();

				}
			}	
			setTags(f, picture);
			setComment(f, picture);
			setLocation(f.getLocationObject(), picture);
		}
	}