<commit_before>/*
  (c) Copyright 2003, Hewlett-Packard Company, all rights reserved.
  [See end of file]
*/

package com.hp.hpl.jena.db.impl;

import com.hp.hpl.jena.graph.*;
import com.hp.hpl.jena.util.iterator.*;
import com.hp.hpl.jena.vocabulary.DB;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 *
 * DBStoreDesc
 * 
 * A wrapper to assist in getting and setting DB information from 
 * a persistent store.
 * 
 * This is written in the style of enhanced nodes - no state is
 * stored in the DBStoreDesc, instead all state is in the
 * underlying graph and this is just provided as a convenience.
 * 
 * (We don't use enhanced nodes because, since we control everything
 * in the persistent store system description, we can avoid any
 * need to handle polymorhphism).
 * 
 * 
 * @author csayers
 * @version $Revision: 1.1 $
 */
public class DBPropDatabase extends DBProp {

	/**
	 * @since Jena 2.0
	 */

	public static final Node_URI dbEngineType = (Node_URI)DB.engineType.getNode();
	public static final Node_URI dbDriverVersion = (Node_URI)DB.driverVersion.getNode();
	public static final Node_URI dbFormatDate = (Node_URI)DB.formatDate.getNode();
	public static final Node_URI dbGraph = (Node_URI)DB.graph.getNode();
	public static final Node_URI dbMaxLiteral = (Node_URI)DB.maxLiteral.getNode(); 
	
	public static final String dbSystemGraphName = "SystemGraph";
	
	protected static SimpleDateFormat dateFormat = null;

	public DBPropDatabase( SpecializedGraph g, String name, String engineType, String driverVersion, String maxLiteral) {
		super(g, new Node_URI(DB.getURI()+name));
		
		if( dateFormat == null ) {
			// Use ISO 8601 Date format and write all dates as UTC time
			dateFormat = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
            dateFormat.setTimeZone( TimeZone.getTimeZone("GMT"));
		}
		
		String today = dateFormat.format( new Date());
		if( engineType != null ) putPropString(dbEngineType, engineType);
		if( driverVersion != null ) putPropString(dbDriverVersion, driverVersion);
		if( maxLiteral != null ) putPropString(dbMaxLiteral, maxLiteral);
		putPropString(dbFormatDate, today);
		
		// Need a set of default graph properties here.
	}
	
	public DBPropDatabase( SpecializedGraph g, Node n) {
		super(g,n);
	}	
	
	public DBPropDatabase( SpecializedGraph g) {
		super(g,findDBPropNode(g));
	}	
	
	public String getName() { return self.getURI().substring(DB.getURI().length()); }
	public String getEngineType() { return getPropString( dbEngineType); };
	public String getDriverVersion() { return getPropString( dbDriverVersion);};
	public String getFormatDate() { return getPropString( dbFormatDate); };
	
	public void addGraph( DBPropGraph g ) {
		putPropNode( dbGraph, g.getNode() );
	}
	
	public ExtendedIterator getAllGraphs() {
		SpecializedGraph.CompletionFlag complete = new SpecializedGraph.CompletionFlag();
		TripleMatch match = new StandardTripleMatch(self, dbGraph, null);
		Iterator matches = graph.find( match, complete );
		return new Map1Iterator(new MapToLSet(), matches);
	}
	
	public ExtendedIterator getAllGraphNames() {
		return new Map1Iterator(new MapGraphToName(), getAllGraphs());
	}
<commit_msg>Add removeGraph<commit_after>/*
  (c) Copyright 2003, Hewlett-Packard Company, all rights reserved.
  [See end of file]
*/

package com.hp.hpl.jena.db.impl;

import com.hp.hpl.jena.graph.*;
import com.hp.hpl.jena.util.iterator.*;
import com.hp.hpl.jena.vocabulary.DB;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 *
 * A wrapper to assist in getting and setting DB information from 
 * a persistent store.
 * 
 * This is written in the style of enhanced nodes - no state is
 * stored in the DBStoreDesc, instead all state is in the
 * underlying graph and this is just provided as a convenience.
 * 
 * (We don't use enhanced nodes because, since we control everything
 * in the persistent store system description, we can avoid any
 * need to handle polymorhphism).
 * 
 * 
 * @author csayers
 * @version $Revision: 1.2 $
 */
public class DBPropDatabase extends DBProp {

	/**
	 * @since Jena 2.0
	 */

	public static final Node_URI dbEngineType = (Node_URI)DB.engineType.getNode();
	public static final Node_URI dbDriverVersion = (Node_URI)DB.driverVersion.getNode();
	public static final Node_URI dbFormatDate = (Node_URI)DB.formatDate.getNode();
	public static final Node_URI dbGraph = (Node_URI)DB.graph.getNode();
	public static final Node_URI dbMaxLiteral = (Node_URI)DB.maxLiteral.getNode(); 
	
	public static final String dbSystemGraphName = "SystemGraph";
	
	protected static SimpleDateFormat dateFormat = null;

	public DBPropDatabase( SpecializedGraph g, String name, String engineType, String driverVersion, String maxLiteral) {
		super(g, new Node_URI(DB.getURI()+name));
		
		if( dateFormat == null ) {
			// Use ISO 8601 Date format and write all dates as UTC time
			dateFormat = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
            dateFormat.setTimeZone( TimeZone.getTimeZone("GMT"));
		}
		
		String today = dateFormat.format( new Date());
		if( engineType != null ) putPropString(dbEngineType, engineType);
		if( driverVersion != null ) putPropString(dbDriverVersion, driverVersion);
		if( maxLiteral != null ) putPropString(dbMaxLiteral, maxLiteral);
		putPropString(dbFormatDate, today);
		
		// Need a set of default graph properties here.
	}
	
	public DBPropDatabase( SpecializedGraph g, Node n) {
		super(g,n);
	}	
	
	public DBPropDatabase( SpecializedGraph g) {
		super(g,findDBPropNode(g));
	}	
	
	public String getName() { return self.getURI().substring(DB.getURI().length()); }
	public String getEngineType() { return getPropString( dbEngineType); };
	public String getDriverVersion() { return getPropString( dbDriverVersion);};
	public String getFormatDate() { return getPropString( dbFormatDate); };
	
	public void addGraph( DBPropGraph g ) {
		putPropNode( dbGraph, g.getNode() );
	}

	public void removeGraph( DBPropGraph g ) {
		SpecializedGraph.CompletionFlag complete = new SpecializedGraph.CompletionFlag();
		TripleMatch match = new StandardTripleMatch(self, dbGraph, g.getNode());
		Iterator matches = graph.find( match, complete);
		if( matches.hasNext() ) {
			graph.delete( (Triple)(matches.next()), complete );
			g.remove();
		}
	}
	
	public ExtendedIterator getAllGraphs() {
		SpecializedGraph.CompletionFlag complete = new SpecializedGraph.CompletionFlag();
		TripleMatch match = new StandardTripleMatch(self, dbGraph, null);
		Iterator matches = graph.find( match, complete );
		return new Map1Iterator(new MapToLSet(), matches);
	}
	
	public ExtendedIterator getAllGraphNames() {
		return new Map1Iterator(new MapGraphToName(), getAllGraphs());
	}

{'fraction_non_alphanumeric': 0.10727625877782758, 'fraction_numerical': 0.004183475272672942, 'mean_word_length': 4.582985821517932, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1554372', 'n_tokens_mistral': 2124, 'n_tokens_neox': 1994, 'n_words': 604}