INSERT INTO SERVICE_ENTRY (KEY_LOGIN_ALIAS, EXTERNAL_ID) SELECT ID_INTERNAL, ALIAS FROM LOGIN_ALIAS; 
UPDATE SERVICE_ENTRY SET KEY_SERVICE = 1,
  HOME_DRIVE = 'H:',
  CREATION_ENTITY = 'bsick@iscte.pt',
  CREATION_ENTITY_DATE = CURDATE(),
  KEY_SERVICE_STATE = 1,
  OJB_CONCRETE_CLASS = 'net.sourceforge.fenixedu.domain.externalServices.LdapServiceEntry' 
 WHERE KEY_SERVICE_STATE = 0;
UPDATE SERVICE_ENTRY s SET HOME_DIRECTORY = (SELECT CONCAT('\\\\areas\\home\\', (TRIM(TRAILING '@iscte.pt' FROM s.EXTERNAL_ID))))
 WHERE KEY_SERVICE_STATE = 0;

INSERT INTO SERVICE_ENTRY (KEY_LOGIN_ALIAS, EXTERNAL_ID) SELECT ID_INTERNAL, ALIAS FROM LOGIN_ALIAS; 
UPDATE SERVICE_ENTRY SET KEY_SERVICE = 2,
  HOME_DRIVE = 'H:',
  CREATION_ENTITY = 'bsick@iscte.pt',
  CREATION_ENTITY_DATE = CURDATE(),
  KEY_SERVICE_STATE = 1,
  OJB_CONCRETE_CLASS = 'net.sourceforge.fenixedu.domain.externalServices.LdapServiceEntry'
 WHERE KEY_SERVICE_STATE = 0;
UPDATE SERVICE_ENTRY s SET HOME_DIRECTORY = (SELECT CONCAT('\\\\areas\\home\\', (TRIM(TRAILING '@iscte.pt' FROM s.EXTERNAL_ID))))
 WHERE KEY_SERVICE_STATE = 0;

INSERT INTO SERVICE_ENTRY (KEY_LOGIN_ALIAS, EXTERNAL_ID) SELECT ID_INTERNAL, ALIAS FROM LOGIN_ALIAS; 
UPDATE SERVICE_ENTRY SET KEY_SERVICE = 3,
  HOME_DRIVE = 'H:',
  CREATION_ENTITY = 'bsick@iscte.pt',
  CREATION_ENTITY_DATE = CURDATE(),
  KEY_SERVICE_STATE = 1,
  OJB_CONCRETE_CLASS = 'net.sourceforge.fenixedu.domain.externalServices.LdapServiceEntry'
 WHERE KEY_SERVICE_STATE = 0;
UPDATE SERVICE_ENTRY s SET HOME_DIRECTORY = (SELECT CONCAT('\\\\areas\\home\\', (TRIM(TRAILING '@iscte.pt' FROM s.EXTERNAL_ID))))
 WHERE KEY_SERVICE_STATE = 0;

INSERT INTO SERVICE_ENTRY (KEY_LOGIN_ALIAS, EXTERNAL_ID) SELECT ID_INTERNAL, ALIAS FROM LOGIN_ALIAS; 
UPDATE SERVICE_ENTRY SET KEY_SERVICE = 4,
  CREATION_ENTITY = 'bsick@iscte.pt',
  CREATION_ENTITY_DATE = CURDATE(),
  KEY_SERVICE_STATE = 1,
  OJB_CONCRETE_CLASS = 'net.sourceforge.fenixedu.domain.externalServices.EmailServiceEntry'
 WHERE KEY_SERVICE_STATE = 0;

INSERT INTO SERVICE_ENTRY (KEY_LOGIN_ALIAS, EXTERNAL_ID) SELECT ID_INTERNAL, ALIAS FROM LOGIN_ALIAS; 
UPDATE SERVICE_ENTRY SET KEY_SERVICE = 5,
  CREATION_ENTITY = 'bsick@iscte.pt',
  CREATION_ENTITY_DATE = CURDATE(),
  KEY_SERVICE_STATE = 1,
  OJB_CONCRETE_CLASS = 'net.sourceforge.fenixedu.domain.externalServices.ElearningServiceEntry'
 WHERE KEY_SERVICE_STATE = 0;
