Ñò
ýÉªWc           @   sl   d  d k  Z  d  d k Z d  d k l Z l Z d e  i  f d „  ƒ  YZ d „  Z e d j o e ƒ  n d S(   iÿÿÿÿN(   t   MeEnhanceFieldDefinitiont   MeFieldDefinitiont   MeEnhancedFieldc           B   s•   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sž   
		data[0]: NAME			LWS
		data[1]: meProfileName	SD
		data[2]: MAPPING		TITLE
		data[3]: DATATYPE		date
		data[4]: PATH			/Fields/Rights/LicensingWindowStart
	c         C   s   t  i  i |  ƒ d  S(   N(   t	   BaseClasst   __init__(   t   self(    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyR      s    c         C   s†   | d } | d } |  i  | ƒ } | t j o t Sd | | f } |  i i | ƒ |  i i ƒ  } t | ƒ o | d d St Sd S(   s3   
		data[0]: fieldName
		data[1]: ME profile Name
		i    i   sˆ   select EF.ID from ME_ENHANCED_FIELD EF join ME_FIELD_DEFINITION FD on (FD.ID = EF.FIELD_ID)where FD.NAME = '%s' and EF.PROFILE_ID = '%s'N(   t   getMeProfileIdt   Falset   cursort   executet   fetchallt   len(   R   t   datat	   fieldNamet   meProfileNamet   meProfileIdt	   statementt   rows(    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyt   checkExistence   s    

c         C   s   d S(   Ni   (    (   R   (    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyt	   getNextId(   s    c         C   si   t  | ƒ d j oI | d } | d } |  i | | ƒ } | t j o g  St ƒ  i | ƒ Sd GHg  Sd S(   s£   
		data[0]: Field Name
		data[1]: ME Profile Name
		
		return an array contains (NAME,MAPPING,DATATYPE,PATH) of the given profile name specified by data[0:1]
		
		i   i    i   sG   MeEnhancedField::backUpExisting:The number of parameters is not correctN(   R   t
   getFieldIdR   R   t	   getFields(   R   R   R   R   t   fieldId(    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyt   backUpExisting+   s    

c   
      C   sù   |  i  | ƒ } | t j o d | GHg  Sd d d d g } d | } |  i i | ƒ |  i i ƒ  } t | ƒ oƒ g  } xz | D]n } h  } xR t d t | ƒ ƒ D]; }	 | |	 d	 j o d | | |	 <q¡ | |	 | | |	 <q¡ W| i | ƒ q Wn | S(
   s6   
		backup all the enhance fields of a given profile
		s@   [Error]MeEnhancedField::backUpAllExisting: profile %s not found!t   NAMEt   MAPPINGt   DATATYPEt   PATHs˜   SELECT FD.NAME, FD.MAPPING, FD.DATATYPE, FD.PATH FROM ME_FIELD_DEFINITION FD JOIN ME_ENHANCED_FIELD EF ON (FD.ID = EF.FIELD_ID) WHERE EF.PROFILE_ID = %di    t    N(	   R   R   R   R	   R
   R   t   ranget   Nonet   append(
   R   t   profileNamet	   profileIdt   enhanceFieldKeyArrayR   R   t   enhanceFieldst   rowt   enhanceFieldt   i(    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyt   backUpAllExistingA   s*    	  c         C   sØ   y° | d } | d } | d } | d } | d } |  i  | ƒ } | t j o t S|  i | ƒ }	 |	 t j o t Sd |  i | |	 g ƒ }
 |
 GH|  i i |
 ƒ |  i ƒ  SWn! t j
 o } | GH|  i ƒ  SXd  S(   Ni    i   i   i   i   s>   INSERT INTO ME_ENHANCED_FIELD (PROFILE_ID, FIELD_ID) VALUES %s(	   R   R   t   insertFieldDefinitiont
   tupleToStrR   R	   t   committ	   Exceptiont   rollback(   R   t   id_R   R   R   t   mappingt   datatypet   pathR   R   R   t   e(    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyt   insert^   s&    




c         C   sC   y |  i  | ƒ |  i ƒ  SWn! t j
 o } | GH|  i ƒ  SXd  S(   N(   t   updateFieldDefinitionR*   R+   R,   (   R   R   R1   (    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyt   updatew   s    c         C   sÔ   | d } | d } |  i  | ƒ } |  i | | ƒ } yw | t j o# d | } | GH|  i i | ƒ n | t j o |  i | ƒ n | t j p | t j o |  i ƒ  SWn! t j
 o } | GH|  i ƒ  SXd  S(   Ni    i   s+   DELETE FROM ME_ENHANCED_FIELD WHERE ID = %d(	   R   R   R   R   R	   t   deleteFieldDefinitionR*   R+   R,   (   R   R   R   R   t	   enhanceIdR   R   R1   (    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyt   delete   s     


c         C   s#   d | } | GH|  i  i | ƒ d S(   s>   
		Description: delete all the enhance field of the profile
		s3   DELETE FROM ME_ENHANCED_FIELD WHERE PROFILE_ID = %dN(   R   R	   (   R   R!   R   (    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyt	   deleteAll–   s    
c         C   s   t  ƒ  } | i | ƒ S(   N(   R    R2   (   R   R   t   fieldDefinition(    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyR(       s    	c         C   s   t  ƒ  } | i | ƒ d  S(   N(   R    R4   (   R   R   R9   (    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyR3   ¤   s    	c         C   s   t  ƒ  } | i | ƒ d  S(   N(   R    R7   (   R   R   R9   (    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyR5   ¨   s    	c         G   s   t  i  ƒ  i | ƒ S(   N(   t   MeSubsProfileR   (   R   R   (    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyR   ¬   s    c         G   s   t  ƒ  i | ƒ S(   N(   R    t   getId(   R   R   (    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyR   ¯   s    c         C   s-   | i  d ƒ p t S| d i ƒ  d j Sd  S(   Nt	   IS_DELETEt   true(   t   has_keyR   t   lower(   R   t   item(    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyt   getIsDelete²   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R'   R2   R4   R7   R8   R(   R3   R5   R   R   RA   (    (    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyR      s    									
					c          C   s   t  ƒ  }  d  S(   N(   R   (   t   meEnF(    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyt   main¸   s    t   __main__(   R   R:   R   R    R   RF   RB   (    (    (    si   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/MeEnhancedField.pyt   <module>   s   ²	