当前位置: 首页>>代码示例>>Java>>正文


Java DescribeSObjectResult类代码示例

本文整理汇总了Java中com.sforce.soap.partner.DescribeSObjectResult的典型用法代码示例。如果您正苦于以下问题:Java DescribeSObjectResult类的具体用法?Java DescribeSObjectResult怎么用?Java DescribeSObjectResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DescribeSObjectResult类属于com.sforce.soap.partner包,在下文中一共展示了DescribeSObjectResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testInferSchemaWithReferenceField

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
@Test
public void testInferSchemaWithReferenceField() {
    Field referenceField = new Field();
    referenceField.setName("reference");
    referenceField.setType(FieldType.string);
    referenceField.setReferenceTo(new String[]{"SomeRecord"});
    referenceField.setRelationshipName("relationship");

    DescribeSObjectResult dsor = new DescribeSObjectResult();
    dsor.setName("MySObjectRecord");
    dsor.setFields(new Field[] { referenceField });

    Schema schema = sRegistry.inferSchema(dsor);

    Schema.Field field = schema.getField("reference");

    assertThat(field.schema().getType(), is(Schema.Type.STRING));
    assertThat(field.getProp(SalesforceSchemaConstants.REF_MODULE_NAME), is("SomeRecord"));
    assertThat(field.getProp(SalesforceSchemaConstants.REF_FIELD_NAME), is("relationship"));
}
 
开发者ID:Talend,项目名称:components,代码行数:21,代码来源:SalesforceAvroRegistryTest.java

示例2: testInferSchemaWithReferenceField

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
@Test
public void testInferSchemaWithReferenceField() {
    Field referenceField = new Field();
    referenceField.setName("reference");
    referenceField.setType(FieldType.string);
    referenceField.setReferenceTo(new String[]{"SomeRecord"});
    referenceField.setRelationshipName("relationship");

    DescribeSObjectResult dsor = new DescribeSObjectResult();
    dsor.setName("MySObjectRecord");
    dsor.setFields(new Field[] { referenceField });

    Schema schema = SalesforceAvroRegistryString.get().inferSchema(dsor);

    Schema.Field field = schema.getField("reference");

    assertThat(field.schema().getType(), is(Schema.Type.STRING));
    assertThat(field.getProp(SalesforceSchemaConstants.REF_MODULE_NAME), is("SomeRecord"));
    assertThat(field.getProp(SalesforceSchemaConstants.REF_FIELD_NAME), is("relationship"));
}
 
开发者ID:Talend,项目名称:components,代码行数:21,代码来源:SalesforceAvroRegistryStringTest.java

示例3: getObjectFields

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
public Field[] getObjectFields(String objectName) throws KettleException
{
 DescribeSObjectResult describeSObjectResult=null;
 try  {
  // Get object
     describeSObjectResult = getBinding().describeSObject(objectName);
     if(describeSObjectResult==null) return null;
   
   if(!describeSObjectResult.isQueryable()){
		throw new KettleException(BaseMessages.getString(PKG, "SalesforceInputDialog.ObjectNotQueryable",this.module));
   }else{
        // we can query this object
          return  describeSObjectResult.getFields();
   }
  } catch(Exception e){
   throw new KettleException(BaseMessages.getString(PKG, "SalesforceInput.Error.GettingModuleFields", this.module),e);
  }finally  {
   if(describeSObjectResult!=null) describeSObjectResult=null;
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:21,代码来源:SalesforceConnection.java

示例4: getObjectFields

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
public Field[] getObjectFields( String objectName ) throws KettleException {
  DescribeSObjectResult describeSObjectResult = null;
  try {
    // Get object
    describeSObjectResult = getBinding().describeSObject( objectName );
    if ( describeSObjectResult == null ) {
      return null;
    }

    if ( !describeSObjectResult.isQueryable() ) {
      throw new KettleException( BaseMessages.getString(
        PKG, "SalesforceInputDialog.ObjectNotQueryable", this.module ) );
    } else {
      // we can query this object
      return describeSObjectResult.getFields();
    }
  } catch ( Exception e ) {
    throw new KettleException( BaseMessages.getString(
      PKG, "SalesforceInput.Error.GettingModuleFields", this.module ), e );
  } finally {
    if ( describeSObjectResult != null ) {
      describeSObjectResult = null;
    }
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:26,代码来源:SalesforceConnection.java

示例5: getEndpointSchema

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
@Override
public Schema getEndpointSchema(RuntimeContainer container, String schemaName) throws IOException {
    try {
        DescribeSObjectResult[] describeSObjectResults = new DescribeSObjectResult[0];
        describeSObjectResults = connectionHolder.connection.describeSObjects(new String[] { schemaName });
        return SalesforceAvroRegistryString.get().inferSchema(describeSObjectResults[0]);
    } catch (ConnectionException e) {
        throw new IOException(e);
    }
}
 
开发者ID:Talend,项目名称:components,代码行数:11,代码来源:SalesforceDataprepSource.java

示例6: getSchema

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
protected Schema getSchema(PartnerConnection connection, String module) throws IOException {
    try {
        DescribeSObjectResult[] describeSObjectResults = new DescribeSObjectResult[0];
        describeSObjectResults = connection.describeSObjects(new String[] { module });
        return SalesforceAvroRegistry.get().inferSchema(describeSObjectResults[0]);
    } catch (ConnectionException e) {
        throw new IOException(e);
    }
}
 
开发者ID:Talend,项目名称:components,代码行数:10,代码来源:SalesforceSourceOrSink.java

示例7: guessSchema

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
@Override
public Schema guessSchema(String soqlQuery) throws IOException {
    SoqlQuery query = SoqlQuery.getInstance();
    query.init(soqlQuery);

    SchemaBuilder.FieldAssembler fieldAssembler = SchemaBuilder.record("GuessedSchema").fields();
    DescribeSObjectResult describeSObjectResult = null;

    try {
        describeSObjectResult = connect(null).connection.describeSObject(query.getDrivingEntityName());
    } catch (ConnectionException e) {
        throw new RuntimeException(e.getMessage());
    }

    Schema entitySchema = SalesforceAvroRegistry.get().inferSchema(describeSObjectResult);

    for (FieldDescription fieldDescription : query.getFieldDescriptions()) {
        Schema.Field schemaField = entitySchema.getField(fieldDescription.getSimpleName());

        SchemaBuilder.FieldBuilder builder = fieldAssembler.name(fieldDescription.getFullName());

        Schema fieldType = null;
        if (schemaField != null) {
            Map<String, Object> props = schemaField.getObjectProps();
            for (Map.Entry<String, Object> entry : props.entrySet()) {
                builder.prop(entry.getKey(), String.valueOf(entry.getValue()));
            }
            fieldType = schemaField.schema();
        } else {
            fieldType = DEFAULT_GUESS_SCHEMA_TYPE;
        }
        builder.type(fieldType).noDefault();
    }

    return (Schema) fieldAssembler.endRecord();
}
 
开发者ID:Talend,项目名称:components,代码行数:37,代码来源:SalesforceSourceOrSink.java

示例8: testPickList

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
@Test
public void testPickList() throws Exception {
    DescribeSObjectResult describeSObjectResult = new DescribeSObjectResult();
    Field pickList = new Field();
    pickList.setName("pickList");
    pickList.setType(FieldType.picklist);
    describeSObjectResult.setFields(new Field[] { pickList });

    Schema schema = SalesforceAvroRegistryString.get().inferSchema(describeSObjectResult);

    assertThat(1, is(schema.getFields().size()));
}
 
开发者ID:Talend,项目名称:components,代码行数:13,代码来源:SalesforceAvroRegistryStringTest.java

示例9: testPickListWithParent

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
@Test
public void testPickListWithParent() throws Exception {
    DescribeSObjectResult describeSObjectResult = new DescribeSObjectResult();
    Field pickList = new Field();
    pickList.setName("pickList");
    pickList.setType(FieldType.picklist);
    pickList.setCompoundFieldName("parent");
    describeSObjectResult.setFields(new Field[] { pickList });

    Schema schema = SalesforceAvroRegistryString.get().inferSchema(describeSObjectResult);

    assertTrue(schema.getFields().isEmpty());
}
 
开发者ID:Talend,项目名称:components,代码行数:14,代码来源:SalesforceAvroRegistryStringTest.java

示例10: testAddressTypeFilter

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
@Test
public void testAddressTypeFilter() throws Exception {
    DescribeSObjectResult describeSObjectResult = new DescribeSObjectResult();
    Field address = new Field();
    address.setName("address");
    address.setType(FieldType.address);
    describeSObjectResult.setFields(new Field[] { address });

    Schema schema = SalesforceAvroRegistryString.get().inferSchema(describeSObjectResult);

    assertThat(0, is(schema.getFields().size()));
}
 
开发者ID:Talend,项目名称:components,代码行数:13,代码来源:SalesforceAvroRegistryStringTest.java

示例11: testLocationTypeFilter

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
@Test
public void testLocationTypeFilter() throws Exception {
    DescribeSObjectResult describeSObjectResult = new DescribeSObjectResult();
    Field location = new Field();
    location.setName("location");
    location.setType(FieldType.location);
    describeSObjectResult.setFields(new Field[] { location });

    Schema schema = SalesforceAvroRegistryString.get().inferSchema(describeSObjectResult);

    assertThat(0, is(schema.getFields().size()));
}
 
开发者ID:Talend,项目名称:components,代码行数:13,代码来源:SalesforceAvroRegistryStringTest.java

示例12: transaction

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
@Override
public ConfigDiff transaction(ConfigSource config,
        Schema schema, int taskCount,
        OutputPlugin.Control control)
{
    PluginTask task = config.loadConfig(PluginTask.class);
    logger = Exec.getLogger(getClass());
    
    if (task.getResultDir().isPresent() && task.getResultDir().get() != null) {
        File resultDir = new File(task.getResultDir().get());
        if (!resultDir.exists() || !resultDir.isDirectory()) {
            logger.error("{} is not exist or is not directory.", task.getResultDir().get());
            throw new RuntimeException(task.getResultDir().get() + " is not exist or is not directory.");
        }
    }
    
    final String username = task.getUsername();
    final String password = task.getPassword();
    final String loginEndpoint = task.getLoginEndpoint().get();
    try {
        if (client == null) {
            ConnectorConfig connectorConfig = new ConnectorConfig();
            connectorConfig.setUsername(username);
            connectorConfig.setPassword(password);
            connectorConfig.setAuthEndpoint(loginEndpoint + "/services/Soap/u/" +task.getVersion().get() + "/");

            client = Connector.newConnection(connectorConfig);
            GetUserInfoResult userInfo = client.getUserInfo();
            logger.info("login successful with {}", userInfo.getUserName());
            externalIdToObjectNameMap = new HashMap<>();
            DescribeSObjectResult describeResult = client.describeSObject(task.getSObject());
            for (Field field : describeResult.getFields()) {
                if (field.getType() == FieldType.reference) {
                    externalIdToObjectNameMap.put(field.getRelationshipName(), field.getReferenceTo()[0]);
                }
            }
        }
    } catch(ConnectionException ex) {
        logger.error("Login error. Please check your credentials.");
        throw new RuntimeException(ex);
    }
        
    control.run(task.dump());
    return Exec.newConfigDiff();
}
 
开发者ID:tzmfreedom,项目名称:embulk-output-salesforce,代码行数:46,代码来源:SalesforceOutputPlugin.java

示例13: processDocumentObjectFields

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
/**
 * Document the Object Fields.
 */
protected void processDocumentObjectFields()
{
	try
	{
		initSalesforceConnection();
		
		DescribeSObjectResult[] describeSObjectResults = partnerConnection.describeSObjects(new String[] {objectName});
		if (describeSObjectResults != null && describeSObjectResults.length > 0) {
			DescribeSObjectResult describeSObjectResult = describeSObjectResults[0];
			Field[] fields = describeSObjectResult.getFields();
			for (int i = 0; i < fields.length; i++) {
				Field describeField = fields[i];
				
				String fieldApiName = describeField.getName();
				ObjectField field = new ObjectField();
				objectFieldMap.put(fieldApiName.toLowerCase(), field);
				
				field.fieldApiName = fieldApiName;
				field.fieldLabel = describeField.getLabel();
				field.dataType = describeField.getType().toString();
				field.formula = describeField.getCalculatedFormula();
				field.helpText = describeField.getInlineHelpText();
				if (describeField.isUnique()) {
					if (describeField.isCaseSensitive()) {
						field.unique = "Case Sensitive";
					} else {
						field.unique = "Case Insensitive";
					}
				}
				field.externalId = describeField.isExternalId();
			}
		}
		
		populateMetadataValues();
		populateCreatedDate();
		populateLayouts();
		populateFieldTrip();
		
		writeCSV();
	}
	catch (Exception ex)
	{
		String error = "Error trying to document object fields\n";
		error += ex.getMessage();
		ex.printStackTrace();
		throw new BuildException(error, ex);
	}
}
 
开发者ID:YBS,项目名称:YBS-SFDC-Build,代码行数:52,代码来源:DocumentObjectFields.java

示例14: testGuessSchema

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
/**
 * Checks {@link SalesforceSourceOrSink#guessSchema(String)} returns the
 * {@link org.apache.avro.Schema} with date and string type
 */
@Test
public void testGuessSchema() throws Exception {
    String field0Name = "Id";
    String field1Name = "LastModifiedDate";
    String field2Name = "LastActivityDate";

    String drivingEntity = "Account";

    String soql = new StringBuilder().append("SELECT").append(" ")
            .append(field0Name).append(",").append(SPACE)
            .append(field1Name).append(",").append(SPACE)
            .append(field2Name).append(SPACE)
            .append("FROM").append(SPACE)
            .append(drivingEntity).toString();

    final PartnerConnection partnerConnectionMock = Mockito.mock(PartnerConnection.class);

    class SalesforceSourceOrSinkChild extends SalesforceSourceOrSink {
        @Override
        protected ConnectionHolder connect(RuntimeContainer container) {
            ConnectionHolder connectionHolder = new ConnectionHolder();
            connectionHolder.connection = partnerConnectionMock;
            return connectionHolder;
        }
    }

    Field field0 = new Field();
    field0.setName(field0Name);
    field0.setType(FieldType.string);

    Field field1 = new Field();
    field1.setName(field1Name);
    field1.setType(FieldType.date);

    Field field2 = new Field();
    field2.setName(field2Name);
    field2.setType(FieldType.date);

    Field[] fields = new Field[3];
    fields[0] = field0;
    fields[1] = field1;
    fields[2] = field2;

    DescribeSObjectResult describeSObjectResult = new DescribeSObjectResult();
    describeSObjectResult.setFields(fields);

    Mockito.when(partnerConnectionMock.describeSObject(drivingEntity)).thenReturn(describeSObjectResult);

    SalesforceSourceOrSinkChild salesforceSourceOrSinkChild = new SalesforceSourceOrSinkChild();
    salesforceSourceOrSinkChild.initialize(runtimeContainerMock, properties);

    Schema resultSchema = salesforceSourceOrSinkChild.guessSchema(soql);

    LOGGER.debug("result schema: " + resultSchema.toString());

    Assert.assertEquals("GuessedSchema", resultSchema.getName());

    Assert.assertEquals(field0Name, resultSchema.getFields().get(0).name());


    Assert.assertEquals(field1Name, resultSchema.getFields().get(1).name());
    Assert.assertEquals("java.util.Date",
            AvroUtils.unwrapIfNullable(resultSchema.getFields().get(1).schema()).getProp("java-class"));
    Assert.assertEquals("yyyy-MM-dd",
            resultSchema.getFields().get(1).getProp(SchemaConstants.TALEND_COLUMN_PATTERN));


    Assert.assertEquals(field2Name, resultSchema.getFields().get(2).name());
    Assert.assertEquals("java.util.Date",
            AvroUtils.unwrapIfNullable(resultSchema.getFields().get(2).schema()).getProp("java-class"));
    Assert.assertEquals("yyyy-MM-dd",
            resultSchema.getFields().get(2).getProp(SchemaConstants.TALEND_COLUMN_PATTERN));
}
 
开发者ID:Talend,项目名称:components,代码行数:78,代码来源:SalesforceSourceOrSinkTest.java

示例15: connectSalesforce

import com.sforce.soap.partner.DescribeSObjectResult; //导入依赖的package包/类
public void connectSalesforce() throws KettleException {
 
String username=environmentSubstitute(meta.getUserName());
String password = environmentSubstitute(meta.getPassword());
String module = environmentSubstitute(meta.getModule());
String condition = environmentSubstitute(meta.getCondition()); 
String timeout= environmentSubstitute(meta.getTimeOut()); 

// connect and return binding
data.binding=getBinding(data.URL,username, password, module, condition,timeout);

if(data.binding==null)  throw new KettleException(Messages.getString("SalesforceInput.Exception.CanNotGetBiding"));


   try{
   	
	// check if we can query this Object
	
    DescribeSObjectResult describeSObjectResult = data.binding.describeSObject(module);
        
    if (describeSObjectResult == null) throw new KettleException(Messages.getString("SalesforceInput.ErrorGettingObject"));
        
    if(!describeSObjectResult.isQueryable()) throw new KettleException(Messages.getString("SalesforceInputDialog.ObjectNotQueryable",module));
	
    // Built SQL statement
    String SQLString=BuiltSQl();
        
    if (log.isDetailed()) logDetailed(Messages.getString("SalesforceInput.Log.SQLString") + " : " +  SQLString);        
    
    if(meta.includeSQL()) data.SQL=SQLString;
   	if(meta.includeTimestamp()) data.Timestamp= data.binding.getServerTimestamp().toString();
		if(log.isDebug()) Messages.getString("SalesforceInput.Log.ServerTimestamp",""+data.binding.getServerTimestamp());
		
   	// return query result
       data.qr = data.binding.query(SQLString);
       
       data.limitReached = true;
       data.recordcount=data.qr.getSize();
       if(data.recordcount>0) 
       {
       	data.limitReached = false;	
       	data.nrRecords=data.qr.getRecords().length;
       }
       
       if (log.isDetailed()) logDetailed(Messages.getString("SalesforceInput.Log.RecordCount") + " : " +  data.recordcount);      
       
}catch(Exception e)
{
	throw new KettleException(e);
}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:52,代码来源:SalesforceInput.java


注:本文中的com.sforce.soap.partner.DescribeSObjectResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。