本文整理汇总了Java中org.pentaho.metadata.model.Domain类的典型用法代码示例。如果您正苦于以下问题:Java Domain类的具体用法?Java Domain怎么用?Java Domain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Domain类属于org.pentaho.metadata.model包,在下文中一共展示了Domain类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: open
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
@Override
public boolean open(Node transNode, String fname, boolean importfile) {
try {
String xml = KettleVFS.getTextFileContent(fname, Const.XML_ENCODING);
Domain domain = new SerializationService().deserializeDomain(xml);
StarDomain starDomain = new StarDomain();
starDomain.setDomain(domain);
starDomain.setFilename(fname);
createTabForModel(starDomain, ModelerHelper.MODELER_NAME);
PropsUI.getInstance().addLastFile(LastUsedFile.FILE_TYPE_SCHEMA, fname, null, false, null);
Spoon.getInstance().addMenuLast();
return true;
} catch(Exception e) {
new ErrorDialog(Spoon.getInstance().getShell(), "Error", "There was an error opening model from file '"+fname+"'", e);
}
return false;
}
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:19,代码来源:StarModelerPerspective.java
示例2: processFactTableName
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
private String processFactTableName() {
String theName = null;
String xmiFileLocation = getXmiFileLocation();
if(xmiFileLocation == null){
return BaseMessages.getString(IVisualization.class,"unavailable");
}
Domain theDomain = ModelerHelper.getInstance().loadDomain(xmiFileLocation);
List<IPhysicalModel> theModels = theDomain.getPhysicalModels();
if (theModels != null && theModels.size() > 0) {
IPhysicalModel theModel = theModels.get(0);
List<? extends IPhysicalTable> theTables = theModel.getPhysicalTables();
if (theTables != null && theTables.size() > 0) {
IPhysicalTable theTable = theTables.get(0);
theName = theTable.getName(LocalizedString.DEFAULT_LOCALE);
}
}
return theName;
}
开发者ID:pentaho,项目名称:pdi-agile-bi-plugin,代码行数:19,代码来源:PRPTVisualizationController.java
示例3: serializeIntoDomain
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
@Test
public void serializeIntoDomain() {
KettleModelerSource source = new KettleModelerSource();
source.setFilename("filename");
source.setMetaId("metaId");
source.setRepositoryName("repositoryName");
Domain domain = new Domain();
LogicalModel lm = new LogicalModel();
domain.addLogicalModel(lm);
source.serializeIntoDomain(domain);
assertEquals(source.getSourceType(), lm.getProperty(source.getSourceTypePropertyName()));
assertEquals(source.getFilename(), lm.getProperty(source.getFilenamePropertyName()));
assertEquals(source.getMetaId(), lm.getProperty(source.getMetaIdPropertyName()));
assertEquals(source.getRepositoryName(), lm.getProperty(source.getRepositoryNamePropertyName()));
}
开发者ID:pentaho,项目名称:pdi-agile-bi-plugin,代码行数:20,代码来源:KettleModelerSourceTest.java
示例4: fromXML
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
public Query fromXML( IMetadataDomainRepository repo, Document doc ) throws PentahoMetadataException {
// get the domain id
String domainId = getElementText( doc, "domain_id" ); //$NON-NLS-1$
Domain domain = repo.getDomain( domainId );
if ( domain == null ) {
if ( domainId != null && !domainId.contains( ".xmi" ) ) {
domain = repo.getDomain( domainId + ".xmi" );
}
if ( domain != null ) {
logger.warn( String.format( "Metadata model [%1$s] was requested, but the model doesn't exist. "
+ "Substituting [%1$s.xmi] instead as a legacy fallback. "
+ "Please change your reports to reference %1$s.xmi instead", domainId ) );
}
}
if ( domain == null ) {
// need to throw an error
logger.error( String.format( "Metadata model [%1$s] doesn't exist. "
+ "Please check the existence of the model", domainId ) );
throw new PentahoMetadataException( Messages.getErrorString(
"QueryXmlHelper.ERROR_0009_DOMAIN_INSTANCE_NULL", domainId ) ); //$NON-NLS-1$
}
return fromXML( doc, domain );
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:26,代码来源:QueryXmlHelper.java
示例5: storeDomain
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
public synchronized void storeDomain( Domain domain, boolean overwrite ) throws DomainIdNullException,
DomainAlreadyExistsException, DomainStorageException {
// stores a domain to system/metadata/DOMAIN_ID.domain.xml
// ISolutionRepository repo = PentahoSystem.get(ISolutionRepository.class, session);
// repo.addSolutionFile(baseUrl, path, fileName, data, overwrite)
if ( domain.getId() == null ) {
// todo: replace with exception
throw new DomainIdNullException( Messages.getErrorString( "IMetadataDomainRepository.ERROR_0001_DOMAIN_ID_NULL" ) ); //$NON-NLS-1$
}
if ( !overwrite && domains != null && domains.get( domain.getId() ) != null ) {
throw new DomainAlreadyExistsException( Messages.getErrorString(
"IMetadataDomainRepository.ERROR_0002_DOMAIN_OBJECT_EXISTS", domain.getId() ) ); //$NON-NLS-1$
}
// adds the domain to the domains list
if ( domains == null ) {
domains = new HashMap<String, Domain>();
}
domains.put( domain.getId(), domain );
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:23,代码来源:InMemoryMetadataDomainRepository.java
示例6: getDomain
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
public Domain getDomain( String id ) {
// for now, lazy load all the domains at once. We could be smarter,
// loading the files as requested.
if ( domains.size() == 0 ) {
reloadDomains();
}
Domain domain = domains.get( id );
if ( domain == null ) {
// try to reference the metadata file implicitly, for backward compatibility
domain = domains.get( id + "/metadata.xmi" );
}
if ( domain != null ) {
SecurityHelper helper = new SecurityHelper();
Domain clone = helper.createSecureDomain( this, domain );
return clone;
} else {
logger.error( Messages.getErrorString( "FileBasedMetadataDomainRepository.ERROR_0006_DOMAIN_NOT_FOUND", id ) ); //$NON-NLS-1$
return null;
}
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:22,代码来源:FileBasedMetadataDomainRepository.java
示例7: generateXmi
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
public String generateXmi( Domain domain ) {
if ( domain == null ) {
logger.error( Messages.getErrorString( "XmiParser.ERROR_0001_DOMAIN_NULL" ) ); //$NON-NLS-1$
return null;
}
try {
StringWriter stringWriter = new StringWriter();
StreamResult result = new StreamResult();
result.setWriter( stringWriter );
TransformerFactory factory = TransformerFactory.newInstance();
Document doc = toXmiDocument( domain );
if ( doc != null ) {
factory.newTransformer().transform( new DOMSource( doc ), result );
return stringWriter.getBuffer().toString();
}
} catch ( Exception e ) {
logger.error( Messages.getErrorString( "XmiParser.ERROR_0002_TO_XML_FAILED" ), e ); //$NON-NLS-1$
}
return null;
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:22,代码来源:XmiParser.java
示例8: bindParentConcept
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
protected void bindParentConcept( Element element, Domain domain, IConcept concept ) {
Element tagged = null;
NodeList pccn = element.getChildNodes();
for ( int j = 0; j < pccn.getLength(); j++ ) {
if ( pccn.item( j ).getNodeType() == Node.ELEMENT_NODE ) {
if ( pccn.item( j ).getNodeName().equals( "CWM:ModelElement.taggedValue" ) ) { //$NON-NLS-1$
tagged = (Element) pccn.item( j );
}
}
}
if ( tagged != null ) {
String
conceptParentName =
getKeyValue( tagged, "CWM:TaggedValue", "tag", "value",
"CONCEPT_PARENT_NAME" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
if ( conceptParentName != null ) {
Concept parent = domain.findConcept( conceptParentName );
if ( parent == null ) {
logger.error( Messages
.getErrorString( "XmiParser.ERROR_0006_FAILED_TO_LOCATE_CONCEPT", conceptParentName ) ); //$NON-NLS-1$
} else {
concept.setParentConcept( parent );
}
}
}
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:27,代码来源:XmiParser.java
示例9: testXmiGenerator
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
@Test
public void testXmiGenerator() throws Exception {
// String str = new XmiParser().generateXmi(new Domain());
// System.out.println(str);
Domain domain = parser.parseXmi( getClass().getResourceAsStream( "/samples/steelwheels.xmi" ) );
String xmi = parser.generateXmi( domain );
ByteArrayInputStream is = new ByteArrayInputStream( xmi.getBytes( "UTF-8" ) );
Domain domain2 = parser.parseXmi( is );
String xml1 = serializeWithOrderedHashmaps( domain );
String xml2 = serializeWithOrderedHashmaps( domain2 );
// note: this does not verify security objects at this time
assertEquals( xml1, xml2 );
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:18,代码来源:XmiParserIT.java
示例10: testMissingDescriptionRef
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
@Test
public void testMissingDescriptionRef() throws Exception {
XmiParser parser = new XmiParser();
Domain domain = parser.parseXmi( getClass().getResourceAsStream( "/missing_ref.xmi" ) );
String xmi = parser.generateXmi( domain );
ByteArrayInputStream is = new ByteArrayInputStream( xmi.getBytes() );
Domain domain2 = parser.parseXmi( is );
ByteArrayInputStream is2 = new ByteArrayInputStream( parser.generateXmi( domain2 ).getBytes() );
Domain domain3 = parser.parseXmi( is2 );
String xml1 = serializeWithOrderedHashmaps( domain2 );
String xml2 = serializeWithOrderedHashmaps( domain3 );
// note: this does not verify security objects at this time
assertEquals( xml1, xml2 );
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:20,代码来源:XmiParserIT.java
示例11: testOlapCalculatedMembers
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
@Test
public void testOlapCalculatedMembers() throws Exception {
XmiParser parser = new XmiParser();
Domain domain = parser.parseXmi( getClass().getResourceAsStream( "/example_olap.xmi" ) );
List<OlapCalculatedMember> members = new ArrayList<OlapCalculatedMember>();
members.add( new OlapCalculatedMember( "Constant One", "Measures", "1", "Currency", false ) );
members.add( new OlapCalculatedMember( "Constant Two", "Measures", "2", "Currency", true ) );
List<OlapCube> cubes = (List<OlapCube>) domain.getLogicalModels().get( 0 ).getProperty( "olap_cubes" );
OlapCube cube = cubes.get( 0 );
cube.setOlapCalculatedMembers( members );
String xmi = parser.generateXmi( domain );
ByteArrayInputStream is = new ByteArrayInputStream( xmi.getBytes() );
Domain domain2 = parser.parseXmi( is );
SerializationService serializer = new SerializationService();
String xml1 = serializeWithOrderedHashmaps( domain );
String xml2 = serializeWithOrderedHashmaps( domain2 );
assertEquals( xml1, xml2 );
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:27,代码来源:XmiParserIT.java
示例12: testWriteAndParseLevelFormatter
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
@Test
public void testWriteAndParseLevelFormatter() throws Exception {
Domain domain = parser.parseXmi( getClass().getResourceAsStream( "/example_olap.xmi" ) );
LogicalModel analysisModel = domain.getLogicalModels().get( 0 );
@SuppressWarnings( "unchecked" )
List<OlapDimension> dims = (List<OlapDimension>) analysisModel.getProperty( LogicalModel.PROPERTY_OLAP_DIMS );
OlapHierarchyLevel firstLevel = dims.get( 0 ).getHierarchies().get( 0 ).getHierarchyLevels().get( 0 );
firstLevel.setFormatter( "InlineMemberFormatter" );
String xmi = parser.generateXmi( domain );
assertTrue( xmi.contains( "<CWM:TaggedValue tag=\"HIERARCHY_LEVEL_FORMATTER\" value=\"InlineMemberFormatter\"" ) );
domain = parser.parseXmi( new ByteArrayInputStream( xmi.getBytes() ) );
analysisModel = domain.getLogicalModels().get( 0 );
@SuppressWarnings( "unchecked" )
List<OlapDimension> parsedDims = (List<OlapDimension>) analysisModel.getProperty( LogicalModel.PROPERTY_OLAP_DIMS );
firstLevel = parsedDims.get( 0 ).getHierarchies().get( 0 ).getHierarchyLevels().get( 0 );
assertEquals( "InlineMemberFormatter", firstLevel.getFormatter() );
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:21,代码来源:XmiParserIT.java
示例13: testAnalyzeImport
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
@Test
public void testAnalyzeImport() throws Exception {
// this test exercises all known places where localized strings are located
XmiParser parser = new XmiParser();
Domain domain = parser.parseXmi( getClass().getResourceAsStream( "/simple_model.xmi" ) );
LocalizationUtil util = new LocalizationUtil();
Properties props = util.exportLocalizedProperties( domain, "en_US" );
List<String> messages = util.analyzeImport( domain, props, "en_US" );
Assert.assertEquals( 0, messages.size() );
props.remove( "[Base].[comments]" );
props.setProperty( "[Test].[Property]", "Test Value" );
messages = util.analyzeImport( domain, props, "en_US" );
Assert.assertEquals( 2, messages.size() );
Assert.assertEquals( messages.get( 0 ), "Key [Base].[comments] is missing from imported bundle" );
Assert.assertEquals( messages.get( 1 ), "Imported key [Test].[Property] is not referenced in domain" );
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:23,代码来源:LocalizationUtilIT.java
示例14: testImportPropertiesIntoAgileBiPublishedModel
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
/**
* Tests the import of localization properties exported from a model that was published from aAgile BI to a BI Server.
**/
@Test
public void testImportPropertiesIntoAgileBiPublishedModel() throws Exception {
// this test exercises all known places where localized strings are located
XmiParser parser = new XmiParser();
Domain domain = null;
domain = parser.parseXmi( getClass().getResourceAsStream( "/agileBiGenerated.xmi" ) );
LocalizationUtil util = new LocalizationUtil();
// Load the properties from the exported properties file
Properties exportedPropertyFileProps = new Properties();
exportedPropertyFileProps.load( getClass().getResourceAsStream( "/agileBiGenerated_en_US.properties" ) );
// import the properties into the domain
List<String> messages = util.analyzeImport( domain, exportedPropertyFileProps, "en_US" );
if ( messages.isEmpty() ) {
Assert.assertTrue( messages.isEmpty() );
} else {
for ( String message : messages ) {
System.out.println( message );
}
Assert.fail( "The analysis of the export failed." );
}
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:28,代码来源:LocalizationUtilIT.java
示例15: testImportPropertiesExportedFromPME
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
/**
* Tests the import of localization properties exported from a model that was published from aAgile BI to a BI Server.
**/
@Test
public void testImportPropertiesExportedFromPME() throws Exception {
// this test exercises all known places where localized strings are located
XmiParser parser = new XmiParser();
Domain domain = null;
domain = parser.parseXmi( getClass().getResourceAsStream( "/exportedFromPME.xmi" ) );
LocalizationUtil util = new LocalizationUtil();
// Load the properties from the exported properties file
Properties exportedPropertyFileProps = new Properties();
exportedPropertyFileProps.load( getClass().getResourceAsStream( "/exportedFromPME_en_US.properties" ) );
// import the properties into the domain
List<String> messages = util.analyzeImport( domain, exportedPropertyFileProps, "en_US" );
if ( messages.isEmpty() ) {
Assert.assertTrue( messages.isEmpty() );
} else {
for ( String message : messages ) {
System.out.println( message );
}
Assert.fail( "The analysis of the export failed." );
}
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:28,代码来源:LocalizationUtilIT.java
示例16: open
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
@Override
public boolean open(Node transNode, String fname, boolean importfile) {
try {
String xml = KettleVFS.getTextFileContent(fname, Const.XML_ENCODING);
Domain domain = new SerializationService().deserializeDomain(xml);
StarDomain starDomain = new StarDomain();
starDomain.setDomain(domain);
starDomain.setFilename(fname);
createTabForDomain(starDomain);
PropsUI.getInstance().addLastFile(LastUsedFile.FILE_TYPE_SCHEMA, fname, null, false, null);
Spoon.getInstance().addMenuLast();
return true;
} catch(Exception e) {
new ErrorDialog(Spoon.getInstance().getShell(), "Error", "There was an error opening model from file '"+fname+"'", e);
}
return false;
}
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:19,代码来源:StarModelerPerspective.java
示例17: setUp
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
final StarDomain starDomain = mock( StarDomain.class );
final Domain domain = mock( Domain.class );
when( domain.getProperty( eq( DefaultIDs.DOMAIN_TARGET_DATABASE ) ) ).thenReturn( "test_domain_target_db" );
when( starDomain.getDomain() ).thenReturn( domain );
final Repository repository = mock( Repository.class );
final RepositoryDirectoryInterface targetDirectory = mock( RepositoryDirectoryInterface.class );
final DatabaseMeta meta = Mockito.mock( DatabaseMeta.class );
Mockito.when( meta.getName() ).thenReturn( "test_domain_target_db" );
final LinkedList<DatabaseMeta> databases = new LinkedList<DatabaseMeta>() {
{
add( meta );
}
};
final String locale = Locale.US.toString();
jobGenerator = new JobGenerator( starDomain, repository, targetDirectory, databases, locale );
}
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:24,代码来源:JobGeneratorTest.java
示例18: getInputStream
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
public InputStream getInputStream() throws FileSystemException {
try {
// read in stream, generate mondrian model, write out stream.
XmiParser parser = new XmiParser();
InputStream inStream;
File file = new File( fileObject.getFileRef() );
if ( file.exists() ) {
inStream = new FileInputStream( file );
} else {
inStream = new URL( fileObject.getFileRef() ).openStream();
}
Domain domain = parser.parseXmi( inStream );
String locale = Locale.getDefault().toString();
if ( domain.getLocales().size() > 0 ) {
locale = domain.getLocales().get( 0 ).getCode();
}
if ( domain.getLogicalModels().size() == 0 ) {
throw new Exception( "Domain " + fileObject.getFileRef() + " does not contain model." );
}
LogicalModel lModel = domain.getLogicalModels().get( 0 );
if ( domain.getLogicalModels().size() > 1 ) {
lModel = domain.getLogicalModels().get( 1 );
}
MondrianModelExporter exporter = new MondrianModelExporter( lModel, locale );
String mondrianSchema = exporter.createMondrianModelXML();
inputStream = new ByteArrayInputStream( mondrianSchema.getBytes() );
} catch ( Exception e ) {
throw new FileSystemException( e.getLocalizedMessage(), e );
}
isOpen = true;
return inputStream;
}
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:37,代码来源:MetadataToMondrianVfsFileContent.java
示例19: getDataSource
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
public DataSource getDataSource( String dsName ) throws DBDatasourceServiceException {
Domain domain = null;
try {
InputStream inStream;
XmiParser parser = new XmiParser();
File file = new File( dsName );
if ( file.exists() ) {
inStream = new FileInputStream( file );
} else {
inStream = new URL( dsName ).openStream();
}
domain = parser.parseXmi( inStream );
} catch ( Exception e ) {
throw new DBDatasourceServiceException( e );
}
if ( domain.getPhysicalModels().size() == 0 || !( domain.getPhysicalModels().get(
0 ) instanceof SqlPhysicalModel ) ) {
throw new DBDatasourceServiceException( "No SQL Physical Model Available" );
}
SqlPhysicalModel model = (SqlPhysicalModel) domain.getPhysicalModels().get( 0 );
DatabaseMeta databaseMeta = ThinModelConverter.convertToLegacy( model.getId(), model.getDatasource() );
return new DatabaseMetaDataSource( databaseMeta );
}
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:28,代码来源:XmiToDatabaseMetaDatasourceService.java
示例20: generatePhysicalModelButton
import org.pentaho.metadata.model.Domain; //导入依赖的package包/类
protected void generatePhysicalModelButton(StarDomain starDomain) {
try {
List<DatabaseMeta> sharedDatabases = SharedDatabaseUtil.loadSharedDatabases();
MetadataGenerator generator = new MetadataGenerator(starDomain.getDomain(), sharedDatabases);
Domain physicalMetadataModel = generator.generatePhysicalMetadataModel();
System.out.println("Generated physical model: "+physicalMetadataModel.getName(defaultLocale));
} catch(Exception e) {
new ErrorDialog(Spoon.getInstance().getShell(),
BaseMessages.getString(PKG, "StarModelerPerspective.ErrorGeneratingPhysicalModel.Title"),
BaseMessages.getString(PKG, "StarModelerPerspective.ErrorGeneratingPhysicalModel.Message"),
e);
}
}
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:16,代码来源:StarModelerPerspective.java
注:本文中的org.pentaho.metadata.model.Domain类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论