DROP TABLE CA_FILETYPE CASCADE CONSTRAINTS
/

CREATE TABLE CA_FILETYPE
(
    ID VARCHAR2(20),
    CREATINGSOFTWARE VARCHAR2(50) NOT NULL,
    CREATINGSOFTWAREVERSION VARCHAR2(10),
	FILEEXTENSION VARCHAR(5) NOT NULL,
	FILEZIPEXTENSION VARCHAR(10) NOT NULL,
    FILECATEGORY VARCHAR2(50) NOT NULL CONSTRAINT CA_FILETYPE_CK1 CHECK (FILECATEGORY IN ('MEASURED_BIOASSAY', 'DERIVED_BIOASSAY', 'ARRAY_DESIGN', 'MAGEML', 'NON_PARSEABLE', 'OTHER')),
	REQUIRED NUMBER(1) DEFAULT 1 NOT NULL,
	DESCRIPTION VARCHAR(400),
    OJBCONCRETECLASS VARCHAR2(100) NOT NULL
)
/

COMMENT ON TABLE CA_FILETYPE IS 'Support for the redesigned Hybridization File Upload: Define pre-defined file types.'
/

COMMENT ON COLUMN CA_FILETYPE.FILEZIPEXTENSION IS 'This is the extension of the zipped file containing the original uploaded file created for more efficient upload. For example, if the uploaded file name is HG-U133B-1.CHP, the zip file name is to be HG-U133B-1_CHP.ZIP'
/

ALTER TABLE CA_FILETYPE
    ADD CONSTRAINT CA_FILETYPE_PK
PRIMARY KEY (ID)
/

INSERT INTO CA_FILETYPE(ID, CREATINGSOFTWARE, CREATINGSOFTWAREVERSION, FILEEXTENSION, FILEZIPEXTENSION, FILECATEGORY, REQUIRED, DESCRIPTION, OJBCONCRETECLASS)
VALUES ('GenePixGprFile', 'GenePix', '1.0', 'gpr', '_gpr.zip', 'MEASURED_BIOASSAY', 1, 'A GPR file to parse to MeasuredBioAssay.', 'gov.nih.nci.caarray.common.data.fileupload2.HybridizationFileType')
/

INSERT INTO CA_FILETYPE(ID, CREATINGSOFTWARE, CREATINGSOFTWAREVERSION, FILEEXTENSION, FILEZIPEXTENSION, FILECATEGORY, REQUIRED, DESCRIPTION, OJBCONCRETECLASS)
VALUES ('GenePixGpsFile', 'GenePix', '1.0', 'gps', '_gps.zip', 'NON_PARSEABLE', 0, 'An optional GPS file.', 'gov.nih.nci.caarray.common.data.fileupload2.HybridizationFileType')
/

INSERT INTO CA_FILETYPE(ID, CREATINGSOFTWARE, CREATINGSOFTWAREVERSION, FILEEXTENSION, FILEZIPEXTENSION, FILECATEGORY, REQUIRED, DESCRIPTION, OJBCONCRETECLASS)
VALUES ('GenePixGalFile', 'GenePix', '1.0', 'gal', '_gal.zip', 'ARRAY_DESIGN', 1, 'A GAL file to parse to an ArrayDesign.', 'gov.nih.nci.caarray.common.data.fileupload2.FileType')
/

INSERT INTO CA_FILETYPE(ID, CREATINGSOFTWARE, CREATINGSOFTWAREVERSION, FILEEXTENSION, FILEZIPEXTENSION, FILECATEGORY, REQUIRED, DESCRIPTION, OJBCONCRETECLASS)
VALUES ('GenePixGalSpotFile', 'GenePix From UCSF Spot', '1.0', 'gal', '_gal.zip', 'ARRAY_DESIGN', 1, 'A GenePix''s GAL file converted from UCSF Spot.', 'gov.nih.nci.caarray.common.data.fileupload2.FileType')
/

INSERT INTO CA_FILETYPE(ID, CREATINGSOFTWARE, CREATINGSOFTWAREVERSION, FILEEXTENSION, FILEZIPEXTENSION, FILECATEGORY, REQUIRED, DESCRIPTION, OJBCONCRETECLASS)
VALUES ('GenePixGprSpotFile', 'GenePix From UCSF Spot', '1.0', 'gpr', '_gpr.zip', 'MEASURED_BIOASSAY', 1, 'A GenePix''s GPR file converted from UCSF Spot', 'gov.nih.nci.caarray.common.data.fileupload2.HybridizationFileType')
/

INSERT INTO CA_FILETYPE(ID, CREATINGSOFTWARE, CREATINGSOFTWAREVERSION, FILEEXTENSION, FILEZIPEXTENSION, FILECATEGORY, REQUIRED, DESCRIPTION, OJBCONCRETECLASS)
VALUES ('AffyCelFile', 'Affymetrix', '1.0', 'cel', '_cel.zip', 'MEASURED_BIOASSAY', 1, 'An Affymetrix CEL file.', 'gov.nih.nci.caarray.common.data.fileupload2.HybridizationFileType')
/

INSERT INTO CA_FILETYPE(ID, CREATINGSOFTWARE, CREATINGSOFTWAREVERSION, FILEEXTENSION, FILEZIPEXTENSION, FILECATEGORY, REQUIRED, DESCRIPTION, OJBCONCRETECLASS)
VALUES ('AffyChpFile', 'Affymetrix', '1.0', 'chp', '_chp.zip', 'DERIVED_BIOASSAY', 1, 'An Affymetrix CHP file.', 'gov.nih.nci.caarray.common.data.fileupload2.HybridizationFileType')
/

INSERT INTO CA_FILETYPE(ID, CREATINGSOFTWARE, CREATINGSOFTWAREVERSION, FILEEXTENSION, FILEZIPEXTENSION, FILECATEGORY, REQUIRED, DESCRIPTION, OJBCONCRETECLASS)
VALUES ('OtherHybFile', 'Other', '1.0', 'other', '_other.zip', 'OTHER', 0, 'Any hybridization files that don''t match the extension of the file types of other categories.', 'gov.nih.nci.caarray.common.data.fileupload2.HybridizationFileType')
/

INSERT INTO CA_FILETYPE(ID, CREATINGSOFTWARE, CREATINGSOFTWAREVERSION, FILEEXTENSION, FILEZIPEXTENSION, FILECATEGORY, REQUIRED, DESCRIPTION, OJBCONCRETECLASS)
VALUES ('OtherArrayFile', 'Other', '1.0', 'other', '_other.zip', 'OTHER', 0, 'Any array files that don''t match the extension of the file types of other categories.', 'gov.nih.nci.caarray.common.data.fileupload2.FileType')
/

DROP TABLE CA_FILEUPLOADGROUP CASCADE CONSTRAINTS
/

CREATE TABLE CA_FILEUPLOADGROUP
(
    ID NUMBER,    
    PARSINGSTARTDATE DATE,
    PARSINGENDDATE DATE,
    PARSINGSUCCEEDED NUMBER(1) CONSTRAINT CA_FILEUPLOADGROUP_CK1 CHECK (PARSINGSUCCEEDED IN (0, 1, 2, 3)),
	OJBCONCRETECLASS VARCHAR2(100) NOT NULL
)
/

COMMENT ON TABLE CA_FILEUPLOADGROUP IS 'Support FOR the redesigned Hybridization FILE Upload'
/

ALTER TABLE CA_FILEUPLOADGROUP
    ADD CONSTRAINT CA_FILEUPLOADGROUP_PK
PRIMARY KEY (ID)
/

DROP TABLE CA_FILEPARSINGENTRY CASCADE CONSTRAINTS
/

CREATE TABLE CA_FILEPARSINGENTRY
(
    ID NUMBER,    
    PARSINGSTARTDATE DATE NOT NULL,
    PARSINGENDDATE DATE,
    PARSINGSUCCEEDED NUMBER(1) DEFAULT 0 NOT NULL CONSTRAINT CA_FILEPARSINGENTRY_CK1 CHECK (PARSINGSUCCEEDED IN (0, 1, 2, 3)),
    OJBCONCRETECLASS VARCHAR2(100) NOT NULL
)
/

COMMENT ON TABLE CA_FILEPARSINGENTRY IS 'Support FOR the redesigned Hybridization FILE Upload: Define the pairing OF an uploaded hybridization FILE WITH its parsing information once it IS parsed'
/

ALTER TABLE CA_FILEPARSINGENTRY
    ADD CONSTRAINT CA_FILEPARSINGENTRY_PK
PRIMARY KEY (ID)
/

DROP TABLE CA_ARRAYDSGNFILEUPLOADENTRY CASCADE CONSTRAINTS
/

CREATE TABLE CA_ARRAYDSGNFILEUPLOADENTRY
(
    ID NUMBER,    
    FILENAME VARCHAR2(100) NOT NULL,
    UPLOADDATE DATE DEFAULT SYSDATE NOT NULL,
    VALID NUMBER(1) CONSTRAINT CA_ARRAYDSGNFILEUPLOADENTRYCK1 CHECK (VALID IN (0, 1, 2, 3)),
	VALIDATIONDATE DATE,
	FILE_TYPE_ID VARCHAR2(20) NOT NULL,
    FILE_PARSING_ENTRY_ID NUMBER,
	ARRAY_DSGN_FILE_UPLOAD_GRP_ID NUMBER,
    ARRAY_DESIGN_ID NUMBER
)
/

COMMENT ON TABLE CA_ARRAYDSGNFILEUPLOADENTRY IS 'Support FOR the redesigned Hybridization FILE Upload: Define the upload event OF an upload FILE related TO its Hybridization grouping'
/

ALTER TABLE CA_ARRAYDSGNFILEUPLOADENTRY
    ADD CONSTRAINT CA_ARRAYDSGNFILEUPLOADENTPK
PRIMARY KEY (ID)
/

ALTER TABLE CA_ARRAYDSGNFILEUPLOADENTRY
    ADD CONSTRAINT CA_ARRAYDSGNFILEUPLOADENTFK1 FOREIGN KEY (FILE_TYPE_ID)
    REFERENCES CA_FILETYPE(ID)
/


ALTER TABLE CA_ARRAYDSGNFILEUPLOADENTRY
    ADD CONSTRAINT CA_ARRAYDSGNFILEUPLOADENTFK2 FOREIGN KEY (FILE_PARSING_ENTRY_ID)
    REFERENCES CA_FILEPARSINGENTRY(ID)
/

ALTER TABLE CA_ARRAYDSGNFILEUPLOADENTRY
    ADD CONSTRAINT CA_ARRAYDSGNFILEUPLOADENTFK3 FOREIGN KEY (ARRAY_DSGN_FILE_UPLOAD_GRP_ID)
    REFERENCES CA_FILEUPLOADGROUP(ID)
/

ALTER TABLE CA_ARRAYDSGNFILEUPLOADENTRY
    ADD CONSTRAINT CA_ARRAYDSGNFILEUPLOADENTFK4 FOREIGN KEY (ARRAY_DESIGN_ID)
    REFERENCES ARRAYDESIGN(ID)
/

DROP TABLE CA_HYBRIDFILEUPLOADENTRY CASCADE CONSTRAINTS
/

CREATE TABLE CA_HYBRIDFILEUPLOADENTRY
(
    ID NUMBER,    
    FILENAME VARCHAR2(100) NOT NULL,
    UPLOADDATE DATE DEFAULT SYSDATE NOT NULL,
    VALID NUMBER(1) CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_CK1 CHECK (VALID IN (0, 1, 2, 3)),
	VALIDATIONDATE DATE,
	FILE_TYPE_ID VARCHAR2(20) NOT NULL,
    FILE_PARSING_ENTRY_ID NUMBER,
    HYBRID_FILE_UPLOAD_GRP_ID NUMBER,
    EXPERIMENT_ID NUMBER NOT NULL,
    MEASURED_BIOASSAY_ID NUMBER,
    DERIVED_BIOASSAY_ID NUMBER,
    CH1_EXTRACT_ID NUMBER,
    CH1_SPIKED_CONTROL_ID NUMBER,
    CH2_EXTRACT_ID NUMBER,
    CH2_SPIKED_CONTROL_ID NUMBER
)
/

COMMENT ON TABLE CA_HYBRIDFILEUPLOADENTRY IS 'Support FOR the redesigned Hybridization FILE Upload: Define the upload event OF an upload FILE related TO its Hybridization grouping'
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY
    ADD CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_PK
PRIMARY KEY (ID)
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY
    ADD CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_FK1 FOREIGN KEY (FILE_TYPE_ID)
    REFERENCES CA_FILETYPE(ID)
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY
    ADD CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_FK2 FOREIGN KEY (FILE_PARSING_ENTRY_ID)
    REFERENCES CA_FILEPARSINGENTRY(ID)
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY
    ADD CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_FK3 FOREIGN KEY (HYBRID_FILE_UPLOAD_GRP_ID)
    REFERENCES CA_FILEUPLOADGROUP(ID)
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY
    ADD CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_FK4 FOREIGN KEY (EXPERIMENT_ID)
    REFERENCES EXPERIMENT(ID)
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY
    ADD CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_FK5 FOREIGN KEY (MEASURED_BIOASSAY_ID)
    REFERENCES BIOASSAY(ID)
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY
    ADD CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_FK6 FOREIGN KEY (DERIVED_BIOASSAY_ID)
    REFERENCES BIOASSAY(ID)
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY
    ADD CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_FK7 FOREIGN KEY (CH1_EXTRACT_ID)
    REFERENCES BIOMATERIAL(ID)
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY
    ADD CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_FK8 FOREIGN KEY (CH1_SPIKED_CONTROL_ID)
    REFERENCES BIOMATERIAL(ID)
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY
    ADD CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_FK9 FOREIGN KEY (CH2_EXTRACT_ID)
    REFERENCES BIOMATERIAL(ID)
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY
    ADD CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_FK10 FOREIGN KEY (CH2_SPIKED_CONTROL_ID)
    REFERENCES BIOMATERIAL(ID)
/

DROP TABLE CA_CH1FACTORVALUES CASCADE CONSTRAINTS
/

CREATE TABLE CA_CH1FACTORVALUES
(
    HYBRID_FILE_UPLOAD_ENTRY_ID NUMBER NOT NULL,    
    FACTOR_VALUE_ID NUMBER NOT NULL
)
/

COMMENT ON TABLE CA_CH1FACTORVALUES IS 'Support for the redesigned Hybridization File Upload: REPLACE CA_CHANNELONEFACTORVALUES. Define the association OF a hybridization FILE upload WITH its first CHANNEL''s FactorValues'
/

ALTER TABLE CA_CH1FACTORVALUES
    ADD CONSTRAINT CA_CH1FACTORVALUES_PK
PRIMARY KEY (HYBRID_FILE_UPLOAD_ENTRY_ID, FACTOR_VALUE_ID)
/

ALTER TABLE CA_CH1FACTORVALUES
    ADD CONSTRAINT CA_CH1FACTORVALUES_FK1 FOREIGN KEY (HYBRID_FILE_UPLOAD_ENTRY_ID)
    REFERENCES CA_HYBRIDFILEUPLOADENTRY(ID)
/

ALTER TABLE CA_CH1FACTORVALUES
    ADD CONSTRAINT CA_CH1FACTORVALUES_FK2 FOREIGN KEY (FACTOR_VALUE_ID)
    REFERENCES FACTORVALUE(ID)
/

DROP TABLE CA_CH2FACTORVALUES CASCADE CONSTRAINTS
/

CREATE TABLE CA_CH2FACTORVALUES
(
    HYBRID_FILE_UPLOAD_ENTRY_ID NUMBER NOT NULL,    
    FACTOR_VALUE_ID NUMBER NOT NULL
)
/

COMMENT ON TABLE CA_CH2FACTORVALUES IS 'Support for the redesigned Hybridization File Upload: REPLACE CA_CHANNELTWOFACTORVALUES. Define the association OF a hybridization FILE upload WITH its second CHANNEL''s FactorValues'
/

ALTER TABLE CA_CH2FACTORVALUES
    ADD CONSTRAINT CA_CH2FACTORVALUES_PK
PRIMARY KEY (HYBRID_FILE_UPLOAD_ENTRY_ID, FACTOR_VALUE_ID)
/

ALTER TABLE CA_CH2FACTORVALUES
    ADD CONSTRAINT CA_CH2FACTORVALUES_FK1 FOREIGN KEY (HYBRID_FILE_UPLOAD_ENTRY_ID)
    REFERENCES CA_HYBRIDFILEUPLOADENTRY(ID)
/

ALTER TABLE CA_CH2FACTORVALUES
    ADD CONSTRAINT CA_CH2FACTORVALUES_FK2 FOREIGN KEY (FACTOR_VALUE_ID)
    REFERENCES FACTORVALUE(ID)
/

DROP SEQUENCE SEQ_CA_FILEUPLOAD
/

CREATE SEQUENCE SEQ_CA_FILEUPLOAD INCREMENT BY 1 START WITH 1 MINVALUE 1 NOCYCLE
/

ALTER SEQUENCE SEQ_CA_FILEUPLOAD
MINVALUE 0
NOCACHE
/

ALTER TABLE CA_FILETYPE MODIFY (ID VARCHAR2(20))
/

ALTER TABLE EXPERIMENT MODIFY (NAME VARCHAR2(500))
 /

ALTER TABLE BIBLIOGRAPHICREFERENCE MODIFY (PUBLICATION VARCHAR2(500))
/

ALTER TABLE CA_ARRAYDSGNFILEUPLOADENTRY MODIFY (FILE_TYPE_ID VARCHAR2(20))
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY MODIFY (FILE_TYPE_ID VARCHAR2(20))
/

ALTER TABLE CA_FILETYPE DROP CONSTRAINT CA_FILETYPE_CK1
/
 ALTER TABLE CA_FILETYPE ADD CONSTRAINT CA_FILETYPE_CK1 CHECK (FILECATEGORY IN
('MEASURED_BIOASSAY', 'DERIVED_BIOASSAY', 'ARRAY_DESIGN', 'MAGEML', 'NON_PARSEABLE',
'OTHER'))
/

DROP TABLE CA_TOPMOSTBIOMATERIAL
/

CREATE TABLE CA_TOPMOSTBIOMATERIAL
(
  BIOMATERIAL_ID             NUMBER             NOT NULL,
  TOP_PARENT_BIOMATERIAL_ID  NUMBER             NOT NULL
)
/

ALTER TABLE CA_TOPMOSTBIOMATERIAL ADD (
  CONSTRAINT CA_TOPMOSTBIOMATERIAL_FK1 FOREIGN KEY (BIOMATERIAL_ID) 
    REFERENCES BIOMATERIAL (ID))
/

ALTER TABLE CA_TOPMOSTBIOMATERIAL ADD (
  CONSTRAINT CA_TOPMOSTBIOMATERIAL_FK2 FOREIGN KEY (TOP_PARENT_BIOMATERIAL_ID) 
    REFERENCES BIOMATERIAL (ID))
/

ALTER TABLE CA_TOPMOSTBIOMATERIAL
 ADD CONSTRAINT CA_TOPMOSTBIOMATERIAL_UNIQUE
 UNIQUE (TOP_PARENT_BIOMATERIAL_ID, BIOMATERIAL_ID)
 /
 
ALTER TABLE CA_HYBRIDFILEUPLOADENTRY
	 DROP CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_CK1
/

ALTER TABLE CA_HYBRIDFILEUPLOADENTRY ADD
	CONSTRAINT CA_HYBRIDFILEUPLOADENTRY_CK1 CHECK (valid IN(0,1,2,3))
/

 ALTER TABLE CA_FILEUPLOADGROUP
	 DROP CONSTRAINT CA_FILEUPLOADGROUP_CK1
/

ALTER TABLE CA_FILEUPLOADGROUP ADD
  CONSTRAINT CA_FILEUPLOADGROUP_CK1 CHECK (PARSINGSUCCEEDED IN(0,1,2,3))
/

 ALTER TABLE CA_FILEPARSINGENTRY
	 DROP CONSTRAINT CA_FILEPARSINGENTRY_CK1
/

ALTER TABLE CA_FILEPARSINGENTRY ADD
  CONSTRAINT CA_FILEPARSINGENTRY_CK1 CHECK (PARSINGSUCCEEDED IN(0,1,2,3))
/

UPDATE CA_HYBRIDIZATIONFILEUPLOAD SET EXTRACT_ID = NULL WHERE EXTRACT_ID NOT IN (SELECT id FROM BIOMATERIAL)
/

UPDATE CA_HYBRIDIZATIONFILEUPLOAD SET SPIKED_CONTROL_ID = NULL WHERE SPIKED_CONTROL_ID NOT IN (SELECT id FROM BIOMATERIAL)
/

UPDATE CA_HYBRIDIZATIONFILEUPLOAD SET CHANNEL_TWO_EXTRACT_ID = NULL WHERE CHANNEL_TWO_EXTRACT_ID NOT IN (SELECT id FROM BIOMATERIAL)
/

UPDATE CA_HYBRIDIZATIONFILEUPLOAD SET CHANNEL_TWO_SPIKED_CONTROL_ID = NULL WHERE CHANNEL_TWO_SPIKED_CONTROL_ID NOT IN (SELECT id FROM BIOMATERIAL)
/

/*  Not needed since migration java code does the same with synching flags to
filesystem
DECLARE
    newFileUploadGroupId NUMBER;
    newFileUploadEntryId NUMBER;
	newFileParsingEntryId NUMBER;
	currExperimentId NUMBER;
	fileName VARCHAR2(200);
	fileTypeId VARCHAR2(20);
	fileUploadValid NUMBER;
	isParseable BOOLEAN;
	slashPos NUMBER;
	newFileName VARCHAR2(100);
	CURSOR cHybFileUpload IS
      SELECT ID, EXPERIMENT_ID, MEASURED_BIOASSAY_ID, DERIVED_BIOASSAY_ID, EXTRACT_ID, SPIKED_CONTROL_ID, CHANNEL_TWO_EXTRACT_ID, CHANNEL_TWO_SPIKED_CONTROL_ID, CELFILELOCATION, EXPFILELOCATION, TXTFILELOCATION, CHPFILELOCATION, GPRFILELOCATION, GPSFILELOCATION, ARRAYIDENTIFIER, ARRAYBATCHNAME, UPLOADGROUPNAME, GPRSPOTFILELOCATION FROM CA_HYBRIDIZATIONFILEUPLOAD ORDER BY EXPERIMENT_ID;
BEGIN
fileName := NULL;
fileTypeId := NULL;
fileUploadValid := 1;
currExperimentId := 0;
FOR file_upload_rec IN cHybFileUpload LOOP		
	IF currExperimentId <> file_upload_rec.experiment_id THEN
	   currExperimentId := file_upload_rec.experiment_id;
	   SELECT SEQ_CA_FILEUPLOAD.NEXTVAL INTO newFileUploadGroupId FROM dual;	
       INSERT INTO CA_FILEUPLOADGROUP (ID, PARSINGSTARTDATE, PARSINGENDDATE, PARSINGSUCCEEDED, OJBCONCRETECLASS) 
	   VALUES (newFileUploadGroupId, SYSDATE, SYSDATE, 1, 'gov.nih.nci.caarray.services.fileupload2.HybridizationFileUploadGroup'); 
	END IF;
	isParseable := TRUE;
	IF file_upload_rec.CELFILELOCATION IS NOT NULL THEN
	   fileName := file_upload_rec.CELFILELOCATION;
	   fileTypeId := 'AffyCelFile';	   
	ELSIF file_upload_rec.EXPFILELOCATION IS NOT NULL THEN
       fileName := file_upload_rec.EXPFILELOCATION;
	   fileTypeId := 'OtherHybFile';
	   isParseable := FALSE;
	ELSIF file_upload_rec.TXTFILELOCATION IS NOT NULL THEN
	   fileName := file_upload_rec.TXTFILELOCATION;
	   fileTypeId := 'OtherHybFile';
	   isParseable := FALSE;
	ELSIF file_upload_rec.CHPFILELOCATION IS NOT NULL THEN
	   fileName := file_upload_rec.CHPFILELOCATION;
	   fileTypeId := 'AffyChpFile';	   
	ELSIF file_upload_rec.GPRFILELOCATION IS NOT NULL THEN
	   fileName := file_upload_rec.GPRFILELOCATION;
	   fileTypeId := 'GenePixGprFile';
	ELSIF file_upload_rec.GPSFILELOCATION IS NOT NULL THEN
	   fileName := file_upload_rec.GPSFILELOCATION;
	   fileTypeId := 'OtherHybFile';
	   isParseable := FALSE;
	ELSIF file_upload_rec.GPRSPOTFILELOCATION IS NOT NULL THEN
	   fileName := file_upload_rec.GPRSPOTFILELOCATION;
	   fileTypeId := 'GenePixGprSpotFile';	
	END IF;	
	SELECT INSTR(fileName, '\', -1, 1) INTO slashPos FROM dual;
	IF slashPos >= 0 THEN
	   SELECT SUBSTR(fileName, slashPos + 1) INTO newFileName FROM dual;
	   fileName := newFileName;
	END IF;	 
	IF isParseable THEN
	   SELECT SEQ_CA_FILEUPLOAD.NEXTVAL INTO newFileParsingEntryId FROM dual;
 	   INSERT INTO CA_FILEPARSINGENTRY (ID, PARSINGSTARTDATE, PARSINGENDDATE, PARSINGSUCCEEDED, OJBCONCRETECLASS) 
       VALUES (newFileParsingEntryId, SYSDATE, SYSDATE, 1, 'gov.nih.nci.caarray.services.fileupload2.HybridizationFileParsingEntry');
	ELSE
	   newFileParsingEntryId := NULL;
	END IF;	
	SELECT SEQ_CA_FILEUPLOAD.NEXTVAL INTO newFileUploadEntryId FROM dual;
	INSERT INTO CA_HYBRIDFILEUPLOADENTRY (ID, FILENAME, UPLOADDATE, VALID, VALIDATIONDATE, FILE_TYPE_ID, FILE_PARSING_ENTRY_ID, HYBRID_FILE_UPLOAD_GRP_ID, EXPERIMENT_ID, MEASURED_BIOASSAY_ID, DERIVED_BIOASSAY_ID, CH1_EXTRACT_ID, CH1_SPIKED_CONTROL_ID, CH2_EXTRACT_ID, CH2_SPIKED_CONTROL_ID) 
    VALUES (newFileUploadEntryId, fileName, SYSDATE, 1, SYSDATE, fileTypeId, newFileParsingEntryId, newFileUploadGroupId, file_upload_rec.experiment_id, file_upload_rec.MEASURED_BIOASSAY_ID, file_upload_rec.DERIVED_BIOASSAY_ID, file_upload_rec.EXTRACT_ID, file_upload_rec.SPIKED_CONTROL_ID, file_upload_rec.CHANNEL_TWO_EXTRACT_ID, file_upload_rec.CHANNEL_TWO_SPIKED_CONTROL_ID);
	IF isParseable THEN
	   INSERT INTO CA_CH1FACTORVALUES(HYBRID_FILE_UPLOAD_ENTRY_ID, FACTOR_VALUE_ID) SELECT newFileUploadEntryId, FACTOR_VALUE_ID FROM CA_CHANNELONEFACTORVALUES WHERE HYBRIDIZATION_FILE_UPLOAD_ID = file_upload_rec.ID;
	   INSERT INTO CA_CH2FACTORVALUES(HYBRID_FILE_UPLOAD_ENTRY_ID, FACTOR_VALUE_ID) SELECT newFileUploadEntryId, FACTOR_VALUE_ID FROM CA_CHANNELTWOFACTORVALUES WHERE HYBRIDIZATION_FILE_UPLOAD_ID = file_upload_rec.ID;
	END IF;	    
END LOOP;
END;
*/

ALTER TABLE CA_CHANNELONEFACTORVALUES DISABLE CONSTRAINT CA_CHANNELONEFACTORVALUES_FK2
/

ALTER TABLE CA_CHANNELTWOFACTORVALUES DISABLE CONSTRAINT CA_CHANNELTWOFACTORVALUES_FK2
/

ALTER TABLE CA_CHANNELONEFACTORVALUES DISABLE CONSTRAINT CA_CHANNELONEFACTORVALUES_FK2
/

ALTER TABLE CA_CHANNELTWOFACTORVALUES DISABLE CONSTRAINT CA_CHANNELTWOFACTORVALUES_FK2
/

ALTER TABLE CA_HYBRIDIZATIONFILEUPLOAD DISABLE CONSTRAINT CA_HYBRIDIZATIONFILEUPLOAD_FK1
/

ALTER TABLE CA_HYBRIDIZATIONFILEUPLOAD DISABLE CONSTRAINT CA_HYBRIDIZATIONFILEUPLOAD_FK2
/

ALTER TABLE CA_HYBRIDIZATIONFILEUPLOAD DISABLE CONSTRAINT CA_HYBRIDIZATIONFILEUPLOAD_FK3
/

ALTER TABLE CA_HYBRIDIZATIONFILEUPLOAD DISABLE CONSTRAINT CA_HYBRIDIZATIONFILEUPLOAD_FK4
/

ALTER TABLE CA_HYBRIDIZATIONFILEUPLOAD DISABLE CONSTRAINT CA_HYBRIDIZATIONFILEUPLOAD_FK5
/

ALTER TABLE CA_HYBRIDIZATIONFILEUPLOAD DISABLE CONSTRAINT CA_HYBRIDIZATIONFILEUPLOAD_FK6
/

ALTER TABLE CA_HYBRIDIZATIONFILEUPLOAD DISABLE CONSTRAINT CA_HYBRIDIZATIONFILEUPLOAD_FK7
/

DECLARE
    newId NUMBER;
BEGIN
    newId := 1015897516080173;
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS )	
	VALUES (newId, 'QT:Flag', 'Flag', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;	             
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS )	
	VALUES (newId, 'QT:Signal Mean', 'Signal Mean', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.MeasuredSignal'); 
	newId := newId + 1;		
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Background Mean', 'Background Mean', 1, 1015897516080024, 100430, 'org.biomage.QuantitationType.MeasuredSignal');
    newId := newId + 1; 	
 	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Signal Median', 'Signal Median', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.MeasuredSignal');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Background Median', 'Background Median', 1, 1015897516080024, 100430, 'org.biomage.QuantitationType.MeasuredSignal');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Signal Mode', 'Signal Mode', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.MeasuredSignal');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Background Mode', 'Background Mode', 1, 1015897516080024, 100430, 'org.biomage.QuantitationType.MeasuredSignal');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Signal Area', 'Signal Area', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Background Area', 'Background Area', 1, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Signal Total', 'Signal Total', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.MeasuredSignal');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Background Total', 'Background Total', 1, 1015897516080024, 100430, 'org.biomage.QuantitationType.MeasuredSignal');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Signal Stdev', 'Signal Stdev', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Background Stdev', 'Background Stdev', 1, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');	
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Shape Regularity', 'Shape Regularity', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Ignored Area', 'Ignored Area', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Spot Area', 'Spot Area', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Ignored Median', 'Ignored Median', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Area To Perimeter', 'Area To Perimeter', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Open Perimeter', 'Open Perimeter', 1, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');	
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:XCoord', 'XCoord', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:YCoord', 'YCoord', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Diameter', 'Diameter', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');	
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Position offset', 'Position offset', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Offset X', 'Offset X', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Offset Y', 'Offset Y', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Expected X', 'Expected X', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Expected Y', 'Expected Y', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');	
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:CM-X', 'CM-X', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:CM-Y', 'CM-Y', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:CM Offset', 'CM Offset', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:CM Offset-X', 'CM Offset-X', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:CM Offset-Y', 'CM Offset-Y', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');				
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Min Diam', 'Min Diam', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Max Diam', 'Max Diam', 0, 1015897516080024, 100430, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Control', 'Control', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Failed Control', 'Failed Control', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Background contamination present', 'Background contamination present', 1, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Signal contamination present', 'Signal contamination present', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1; 
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Ignored % failed', 'Ignored % failed', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Open perimeter failed', 'Open perimeter failed', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Shape regularity failed', 'Shape regularity failed', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Perim-to-area failed', 'Perim-to-area failed', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Offset failed', 'Offset failed', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Empty spot', 'Empty spot', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Negative spot', 'Negative spot', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Selected spot', 'Selected spot', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');
	newId := newId + 1;
	INSERT INTO QUANTITATIONTYPE ( ID, IDENTIFIER, NAME, ISBACKGROUND, SCALE_ID, DATA_TYPE_ID, OJBCONCRETECLASS ) 
	VALUES (newId, 'QT:Saturated spot', 'Saturated spot', 0, 1015897516080024, 100324, 'org.biomage.QuantitationType.SpecializedQuantitationType');		
END;
/

INSERT INTO CA_FILETYPE
(ID, 
 CREATINGSOFTWARE, 
 CREATINGSOFTWAREVERSION, 
 FILEEXTENSION, 
 FILEZIPEXTENSION, 
 FILECATEGORY, 
 REQUIRED, 
 DESCRIPTION, 
 OJBCONCRETECLASS)
VALUES 
('ImaGeneTxtFile', 
 'ImaGene', 
 '6.0', 
 'txt', 
 '_txt.zip', 
 'MEASURED_BIOASSAY', 
 1, 
 'A TXT file to be parsed to a MeasuredBioAssay. This fileType supports data files produced by ImaGene versions 6.0 or earlier. Because the same set of quantitation types are used for all file versions, quantitation columns included in a newer version but not in an older version will be skipped when the older version is parsed.',
'gov.nih.nci.caarray.common.data.fileupload2.HybridizationFileType')
/

DECLARE
maxProtectionElementId NUMBER ;
c BINARY_INTEGER;
BEGIN
  select MAX(NVL(protection_element_id, 1))  into maxProtectionElementId from AS_PROTECTION_ELEMENT  ;
  c := dbms_sql.open_cursor;
  dbms_sql.parse(c, 'CREATE SEQUENCE  SEQ_AS_PROTECTION_ELEMENT INCREMENT BY 1 START WITH ' || (NVL(maxProtectionElementId, 0) + 1)  || ' MINVALUE 1 NOCYCLE', dbms_sql.native);
  dbms_sql.close_cursor(c);      
END ;
/

DECLARE
maxProtGroupElemId NUMBER ;
c BINARY_INTEGER;
BEGIN
  select MAX(NVL(protection_group_element_id, 1))  into maxProtGroupElemId from AS_PROTECTION_GROUP_ELEMENT  ;
  c := dbms_sql.open_cursor;
  dbms_sql.parse(c, 'CREATE SEQUENCE  SEQ_AS_PROTECTION_GROUP_ELEMEN INCREMENT BY 1 START WITH ' || (NVL(maxProtGroupElemId, 0) + 1)  || ' MINVALUE 1 NOCYCLE', dbms_sql.native);
  dbms_sql.close_cursor(c);      
END ;
/

