Exemplo n.º 1
0
 def create_field_as_xml(self, schema_xml):
     """
     :type schema_xml: str
     """
     field = Field(self.context)
     field_schema = XmlSchemaFieldCreationInformation(schema_xml)
     self._create_field_as_xml_query(field_schema, field)
     return field
Exemplo n.º 2
0
    def create_field_as_xml(self, schema_xml, return_type=None):
        """
        Creates a field based on the values defined in the parameters input parameter.

        :param str schema_xml:
        :type return_type: Field
        """
        if return_type is None:
            return_type = Field(self.context)
        self.add_child(return_type)
        field_schema = XmlSchemaFieldCreationInformation(schema_xml)
        qry = ServiceOperationQuery(self, "CreateFieldAsXml", None,
                                    field_schema, "parameters", return_type)
        self.context.add_query(qry)
        return return_type
Exemplo n.º 3
0
    def _build_taxonomy_field_query(self,
                                    name,
                                    ssp_id,
                                    term_set_id,
                                    anchor_id,
                                    field_id=None,
                                    text_field_id=None,
                                    web_id=None,
                                    list_id=None,
                                    target_field=None):
        """

        :param str text_field_id: Text Field Id
        :param str web_id: Web Id
        :param str list_id: List Id
        :param str field_id: Field Id
        :type name: str
        :type ssp_id: str
        :type term_set_id: str
        :type anchor_id: str
        :type target_field: Field
        """

        list_attr = 'List="{{{list_id}}}"'.format(
            list_id=list_id) if list_id is not None else ""

        schema_xml = '''
<Field Type="TaxonomyFieldType" DisplayName="{name}" {list_attr}
       WebId="{web_id}" Required="FALSE" EnforceUniqueValues="FALSE"
       ID="{{{field_id}}}" StaticName="{name}" Name="{name}">
    <Default/>
    <Customization>
        <ArrayOfProperty>
            <Property>
                <Name>SspId</Name>
                <Value xmlns:q1="http://www.w3.org/2001/XMLSchema" p4:type="q1:string"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">{ssp_id}
                </Value>
            </Property>
            <Property>
                <Name>GroupId</Name>
            </Property>
            <Property>
                <Name>TermSetId</Name>
                <Value xmlns:q2="http://www.w3.org/2001/XMLSchema" p4:type="q2:string"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">{term_set_id}
                </Value>
            </Property>
            <Property>
                <Name>AnchorId</Name>
                <Value xmlns:q3="http://www.w3.org/2001/XMLSchema" p4:type="q3:string"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">{anchor_id}
                </Value>
            </Property>
            <Property>
                <Name>UserCreated</Name>
                <Value xmlns:q4="http://www.w3.org/2001/XMLSchema" p4:type="q4:boolean"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false
                </Value>
            </Property>
            <Property>
                <Name>Open</Name>
                <Value xmlns:q5="http://www.w3.org/2001/XMLSchema" p4:type="q5:boolean"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">true
                </Value>
            </Property>
            <Property>
                <Name>TextField</Name>
                <Value xmlns:q6="http://www.w3.org/2001/XMLSchema" p4:type="q6:string"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">{{{text_field_id}}}
                </Value>
            </Property>
            <Property>
                <Name>IsPathRendered</Name>
                <Value xmlns:q7="http://www.w3.org/2001/XMLSchema" p4:type="q7:boolean"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false
                </Value>
            </Property>
            <Property>
                <Name>IsKeyword</Name>
                <Value xmlns:q8="http://www.w3.org/2001/XMLSchema" p4:type="q8:boolean"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false
                </Value>
            </Property>
            <Property>
                <Name>TargetTemplate</Name>
            </Property>
            <Property>
                <Name>CreateValuesInEditForm</Name>
                <Value xmlns:q9="http://www.w3.org/2001/XMLSchema" p4:type="q9:boolean"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">false
                </Value>
            </Property>
            <Property>
                <Name>FilterAssemblyStrongName</Name>
                <Value xmlns:q10="http://www.w3.org/2001/XMLSchema" p4:type="q10:string"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">Microsoft.SharePoint.Taxonomy,
                    Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
                </Value>
            </Property>
            <Property>
                <Name>FilterClassName</Name>
                <Value xmlns:q11="http://www.w3.org/2001/XMLSchema" p4:type="q11:string"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">Microsoft.SharePoint.Taxonomy.TaxonomyField
                </Value>
            </Property>
            <Property>
                <Name>FilterMethodName</Name>
                <Value xmlns:q12="http://www.w3.org/2001/XMLSchema" p4:type="q12:string"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">GetFilteringHtml
                </Value>
            </Property>
            <Property>
                <Name>FilterJavascriptProperty</Name>
                <Value xmlns:q13="http://www.w3.org/2001/XMLSchema" p4:type="q13:string"
                       xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">FilteringJavascript
                </Value>
            </Property>
        </ArrayOfProperty>
    </Customization>
</Field>
'''.format(list_id=list_id,
           name=name,
           list_attr=list_attr,
           web_id=web_id,
           field_id=field_id,
           ssp_id=ssp_id,
           term_set_id=term_set_id,
           anchor_id=anchor_id,
           text_field_id=text_field_id)

        field_schema = XmlSchemaFieldCreationInformation(schema_xml)
        self._create_field_as_xml_query(field_schema, target_field)