Project

General

Profile

« Previous | Next » 

Revision 50977

finalized sources register and update

View differences:

journal-info-form.component.ts
2 2
*  created by myrto on 1/22/2018
3 3
*/
4 4

  
5
import { Component, OnInit } from '@angular/core';
5
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
6 6
import {
7 7
  formErrorInvalidFields, formErrorRequiredFields, formErrorWasntSaved, formSuccessRegisteredDatasource,
8 8
  noServiceMessage
......
15 15
import {
16 16
  Description,
17 17
  softwarePlatformDesc,
18
  platformNameDesc,
19 18
  officialNameDesc,
20 19
  issnDesc,
21 20
  eissnDesc,
......
33 32
  adminEmailDesc
34 33
} from '../../../domain/oa-description';
35 34
import { ValidatorService } from '../../../services/validator.service';
35
import { AuthenticationService } from '../../../services/authentication.service';
36 36

  
37 37
@Component ({
38 38
  selector: 'journal-info-form',
......
50 50
  datasourceClasses: Map<string,string> = new Map<string,string>();
51 51
  classCodes: string[] = [];
52 52

  
53
  newDatasource: Repository;
53
  @Output() emittedInfo: EventEmitter<Repository> = new EventEmitter();
54 54

  
55 55
  group: FormGroup;
56 56
  readonly groupDefinition = {
57 57
    softwarePlatform : '',
58
    platformName : '',
59 58
    officialName : ['', Validators.required],
60 59
    issn : ['', [Validators.required, Validators.minLength(8), Validators.maxLength(8)]],
61 60
    eissn : ['', [Validators.minLength(8), Validators.maxLength(8)]],
......
74 73
  };
75 74

  
76 75
  softwarePlatformDesc : Description = softwarePlatformDesc;
77
  platformNameDesc : Description = platformNameDesc;
78 76
  officialNameDesc : Description = officialNameDesc;
79 77
  issnDesc : Description = issnDesc;
80 78
  eissnDesc : Description = eissnDesc;
......
93 91

  
94 92
  constructor(
95 93
    private fb: FormBuilder,
96
    private repoService: RepositoryService
94
    private repoService: RepositoryService,
95
    private authService: AuthenticationService
97 96
  ) {}
98 97

  
99 98
  ngOnInit() {
......
141 140

  
142 141
  registerDatasource(): boolean {
143 142
    if(this.group.valid){
144
      let newRepo: Repository = {
145
        id: '',
146
        officialName: this.group.get('officialName').value,
147
        englishName: this.group.get('englishName').value,
148
        websiteUrl: this.group.get('websiteUrl').value,
149
        logoUrl: this.group.get('logoUrl').value,
150
        contactEmail: this.group.get('adminEmail').value,
151
        countryName: this.group.get('country').value,
152
        countryCode: null, //this.group.get('officialName').value,
153
        organization: null,
154
        latitude: this.group.get('latitude').value,
155
        longitude: this.group.get('longtitude').value,
156
        timezone: this.group.get('timezone').value,
157
        namespacePrefix: '',
158
        odNumberOfItems: '',
159
        odNumberOfItemsDate: null,
160
        odPolicies: '',
161
        odLanguages: '',
162
        odContentTypes: '',
163
        collectedFrom: '',
164
        inferred: null,
165
        deletedByInference: null,
166
        trust: 0,
167
        inferenceProvenance: '',
168
        dateOfValidation: null,
169
        datasourceClass: this.group.get('journalType').value,
170
        provenanceActionClass: '',
171
        dateOfCollection: null,
172
        typology: this.group.get('softwarePlatform').value,
173
        activationId: '',
174
        mergehomonyms: null,
175
        description: this.group.get('repoDescription').value,
176
        releaseStartDate: null,
177
        releaseEndDate: null,
178
        missionStatementUrl: '',
179
        dataProvider: null,
180
        serviceProvider: null,
181
        databaseAccessType: '',
182
        dataUploadType: '',
183
        databaseAccessRestriction: '',
184
        dataUploadRestriction: '',
185
        versioning: null,
186
        citationGuidelineUrl: '',
187
        qualityManagementKind: '',
188
        pidSystems: '',
189
        certificates: '',
190
        aggregator: '',
191
        issn: this.group.get('issn').value,
192
        eissn: this.group.get('eissn').value,
193
        lissn: this.group.get('lissn').value,
194
        interfaces: [],
195
        availableDiskSpace: '',
196
        securityParameters: '',
197
        protocol: 'oai',
198
        registeredBy: 'ant.lebesis@gmail.com',
199
        datasourceType: 'journal',
200
        datasourceAggregatorId: null,
201
        datasourceOriginalIdValue: null,
202
        datasourceOriginalIdProvenance: '',
203
        datasourceAggregated: false,
204
        datasourceComplianceDegreeValue: '',
205
        datasourceComplianceDegreeEncoding: '',
206
        numberOfObjects: 0,
207
        maxSizeOfDatastructure: 0,
208
        maxNumberOfDataStructures: 0,
209
        registered: true,
210
        extraFields: {  },
211
        piwikInfo: null,
212
        environments: [],
213
        registrationDate: null,
214
        verified: false,
215
        dataCollectionTypes: [],
216
        resourceId: '',
217
        resourceUri: '',
218
        resourceKind: '',
219
        resourceType: '',
220
        dateOfCreation: null,
221

  
222
    };
143
      let newRepo = this.createNewRepository();
223 144
      this.repoService.addRepository('journal',newRepo).subscribe(
224 145
        response => console.log(`${JSON.stringify(response)}`),
225 146
        error => console.log(error)
......
250 171
    return status;
251 172
  }
252 173

  
174
  createNewRepository(): Repository {
175
    let newRepo: Repository = new Repository();
176
    newRepo.dateOfCreation = new Date(Date.now());
177
    newRepo.officialName = this.group.get('officialName').value;
178
    newRepo.englishName = this.group.get('englishName').value;
179
    newRepo.websiteUrl = this.group.get('websiteUrl').value;
180
    newRepo.logoUrl = this.group.get('logoUrl').value;
181
    newRepo.contactEmail = this.group.get('adminEmail').value;
182
    newRepo.countryName = this.countries.filter(x => x.code == this.group.get('country').value)[0].name;
183
    newRepo.countryCode = this.group.get('country').value;
184
    newRepo.organization = this.group.get('institutionName').value;
185
    newRepo.latitude = this.group.get('latitude').value;
186
    newRepo.longitude = this.group.get('longtitude').value;
187
    newRepo.timezone = this.group.get('timezone').value;
188
    newRepo.datasourceClass = this.group.get('journalType').value;
189
    newRepo.typology = this.group.get('softwarePlatform').value;
190
    newRepo.description = this.group.get('repoDescription').value;
191
    newRepo.issn = this.group.get('issn').value;
192
    newRepo.eissn = this.group.get('eissn').value;
193
    newRepo.lissn = this.group.get('lissn').value;
194
    newRepo.registeredBy = this.authService.userEmail;
195
    newRepo.datasourceType = 'journal';
196
    newRepo.registered = true;
253 197

  
198
    this.emittedInfo.emit(newRepo);
199

  
200
    return newRepo;
201
  }
202

  
203

  
254 204
}

Also available in: Unified diff