TSK-623 Add parentKey to classification saved object
This commit is contained in:
parent
801e76498e
commit
f0137f66b8
|
@ -15,15 +15,15 @@ public interface ClassificationService {
|
|||
|
||||
/**
|
||||
* Get the Classification for key and domain. If there's no Classification in the given domain, return the
|
||||
* Classification from the root domain.
|
||||
* Classification from the master domain.
|
||||
*
|
||||
* @param key
|
||||
* the key of the searched-for classifications
|
||||
* @param domain
|
||||
* the domain of the searched-for classifications
|
||||
* @return If exist: domain-specific classification, else root classification
|
||||
* @return If exist: domain-specific classification, else master classification
|
||||
* @throws ClassificationNotFoundException
|
||||
* if no classification is found that matches the key either in domain or in the root domain.
|
||||
* if no classification is found that matches the key either in domain or in the master domain.
|
||||
*/
|
||||
Classification getClassification(String key, String domain) throws ClassificationNotFoundException;
|
||||
|
||||
|
@ -73,7 +73,7 @@ public interface ClassificationService {
|
|||
|
||||
/**
|
||||
* Persists a new classification after adding default values. <br >
|
||||
* The classification will be added to root-domain, too - if not already existing.
|
||||
* The classification will be added to master-domain, too - if not already existing.
|
||||
*
|
||||
* @param classification
|
||||
* the classification to insert
|
||||
|
|
|
@ -82,7 +82,7 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
LOGGER.debug("Method createClassification created classification {}.", classificationImpl);
|
||||
|
||||
if (!classification.getDomain().isEmpty()) {
|
||||
addClassificationToRootDomain(classificationImpl);
|
||||
addClassificationToMasterDomain(classificationImpl);
|
||||
}
|
||||
} finally {
|
||||
taskanaEngine.returnConnection();
|
||||
|
@ -123,53 +123,40 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
}
|
||||
}
|
||||
|
||||
private void addClassificationToRootDomain(ClassificationImpl classificationImpl) {
|
||||
private void addClassificationToMasterDomain(ClassificationImpl classificationImpl) {
|
||||
if (!Objects.equals(classificationImpl.getDomain(), "")) {
|
||||
boolean doesExist = true;
|
||||
ClassificationImpl rootClassification = new ClassificationImpl(classificationImpl);
|
||||
rootClassification.setId(IdGenerator.generateWithPrefix(ID_PREFIX_CLASSIFICATION));
|
||||
rootClassification.setParentId(getClassificationRootDomainParentId(classificationImpl));
|
||||
rootClassification.setDomain("");
|
||||
rootClassification.setIsValidInDomain(false);
|
||||
ClassificationImpl masterClassification = new ClassificationImpl(classificationImpl);
|
||||
masterClassification.setId(IdGenerator.generateWithPrefix(ID_PREFIX_CLASSIFICATION));
|
||||
masterClassification.setParentKey(classificationImpl.getParentKey());
|
||||
masterClassification.setDomain("");
|
||||
masterClassification.setIsValidInDomain(false);
|
||||
try {
|
||||
this.getClassification(rootClassification.getKey(), rootClassification.getDomain());
|
||||
throw new ClassificationAlreadyExistException(rootClassification);
|
||||
if (classificationImpl.getParentKey() != null && !"".equals(classificationImpl.getParentKey())) {
|
||||
masterClassification.setParentId(getClassification(classificationImpl.getParentKey(), "").getId());
|
||||
}
|
||||
this.getClassification(masterClassification.getKey(), masterClassification.getDomain());
|
||||
throw new ClassificationAlreadyExistException(masterClassification);
|
||||
} catch (ClassificationNotFoundException e) {
|
||||
doesExist = false;
|
||||
LOGGER.debug(
|
||||
"Method createClassification: Classification does not exist in root domain. Classification {}.",
|
||||
rootClassification);
|
||||
"Method createClassification: Classification does not exist in master domain. Classification {}.",
|
||||
masterClassification);
|
||||
} catch (ClassificationAlreadyExistException ex) {
|
||||
LOGGER.warn(
|
||||
"Method createClassification: Classification does already exist in root domain. Classification {}.",
|
||||
rootClassification);
|
||||
"Method createClassification: Classification does already exist in master domain. Classification {}.",
|
||||
masterClassification);
|
||||
} finally {
|
||||
if (!doesExist) {
|
||||
classificationMapper.insert(rootClassification);
|
||||
classificationMapper.insert(masterClassification);
|
||||
LOGGER.debug(
|
||||
"Method createClassification: Classification created in root-domain, too. Classification {}.",
|
||||
rootClassification);
|
||||
"Method createClassification: Classification created in master-domain, too. Classification {}.",
|
||||
masterClassification);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getClassificationRootDomainParentId(ClassificationImpl classificationImpl) {
|
||||
String rootParentId = "";
|
||||
try {
|
||||
if (classificationImpl.getParentId() != null && !"".equals(classificationImpl.getParentId())) {
|
||||
rootParentId = this.getClassification(this.getClassification(classificationImpl.getParentId()).getKey(),
|
||||
"")
|
||||
.getId();
|
||||
}
|
||||
} catch (ClassificationNotFoundException e) {
|
||||
LOGGER.warn(
|
||||
"Method getRootDomainParentIdClassification: Cannot find parent classification in Root domain. Classification {}.",
|
||||
classificationImpl);
|
||||
}
|
||||
return rootParentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Classification updateClassification(Classification classification)
|
||||
throws NotAuthorizedException, ConcurrencyException, ClassificationNotFoundException, InvalidArgumentException {
|
||||
|
|
|
@ -35,7 +35,7 @@ public class CreateClassificationAccTest extends AbstractAccTest {
|
|||
userName = "teamlead_1",
|
||||
groupNames = {"group_1", "businessadmin"})
|
||||
@Test
|
||||
public void testCreateRootClassification()
|
||||
public void testCreateMasterClassification()
|
||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
DomainNotFoundException, InvalidArgumentException {
|
||||
long amountOfClassificationsBefore = classificationService.createClassificationQuery().count();
|
||||
|
@ -59,7 +59,7 @@ public class CreateClassificationAccTest extends AbstractAccTest {
|
|||
userName = "teamlead_1",
|
||||
groupNames = {"group_1", "businessadmin"})
|
||||
@Test
|
||||
public void testCreateClassificationWithRootCopy()
|
||||
public void testCreateClassificationWithMasterCopy()
|
||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
DomainNotFoundException, InvalidArgumentException {
|
||||
long amountOfClassificationsBefore = classificationService.createClassificationQuery().count();
|
||||
|
@ -87,7 +87,7 @@ public class CreateClassificationAccTest extends AbstractAccTest {
|
|||
assertNotNull(classification.getId());
|
||||
assertThat(classification.getIsValidInDomain(), equalTo(true));
|
||||
|
||||
// Check root-copy
|
||||
// Check master-copy
|
||||
classification = classificationService.getClassification(classification.getKey(), "");
|
||||
assertNotNull(classification);
|
||||
assertNotNull(classification.getCreated());
|
||||
|
|
|
@ -106,7 +106,7 @@ public class GetClassificationAccTest extends AbstractAccTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetOneClassificationForDomainAndGetClassificationFromRootDomain()
|
||||
public void testGetOneClassificationForDomainAndGetClassificationFromMasterDomain()
|
||||
throws ClassificationNotFoundException {
|
||||
ClassificationService classificationService = taskanaEngine.getClassificationService();
|
||||
Classification classification = classificationService.getClassification("L10000", "DOMAIN_B");
|
||||
|
@ -116,7 +116,7 @@ public class GetClassificationAccTest extends AbstractAccTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetOneClassificationForRootDomain() throws ClassificationNotFoundException {
|
||||
public void testGetOneClassificationForMasterDomain() throws ClassificationNotFoundException {
|
||||
ClassificationService classificationService = taskanaEngine.getClassificationService();
|
||||
Classification classification = classificationService.getClassification("L10000", "");
|
||||
assertNotNull(classification);
|
||||
|
|
|
@ -142,7 +142,7 @@ public class ClassificationServiceImplTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateClassificationInOwnDomainButExistingInRoot()
|
||||
public void testCreateClassificationInOwnDomainButExistingInMaster()
|
||||
throws ClassificationAlreadyExistException, InterruptedException,
|
||||
NotAuthorizedException, DomainNotFoundException, InvalidArgumentException {
|
||||
Instant beforeTimestamp = Instant.now();
|
||||
|
@ -175,7 +175,7 @@ public class ClassificationServiceImplTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateClassificationInOwnDomainAndCopyInRootDomain()
|
||||
public void testCreateClassificationInOwnDomainAndCopyInMasterDomain()
|
||||
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||
InvalidArgumentException {
|
||||
Classification classification = createDummyClassification("");
|
||||
|
@ -202,25 +202,28 @@ public class ClassificationServiceImplTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateChildClassificationInOwnDomainAndCopyInRootDomain()
|
||||
public void testCreateChildClassificationInOwnDomainAndCopyInMasterDomain()
|
||||
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||
InvalidArgumentException {
|
||||
Classification classification = createDummyClassification("");
|
||||
classification.setParentId("parentId");
|
||||
ClassificationImpl parentRootClassification = (ClassificationImpl) createDummyClassification("ParentIdRoot");
|
||||
parentRootClassification.setKey("ParentKey");
|
||||
parentRootClassification.setDomain("");
|
||||
classification.setParentKey("ParentKey");
|
||||
ClassificationImpl parentDomainClassification = (ClassificationImpl) createDummyClassification("ParentId");
|
||||
parentDomainClassification.setKey("ParentKey");
|
||||
ClassificationImpl parentMasterClassification = (ClassificationImpl) createDummyClassification("ParentIdMaster");
|
||||
parentMasterClassification.setKey("ParentKey");
|
||||
parentMasterClassification.setDomain("");
|
||||
doReturn(null).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(),
|
||||
classification.getDomain());
|
||||
doReturn(null).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(), "");
|
||||
doReturn(parentRootClassification).when(classificationMapperMock).findByKeyAndDomain("ParentKey", "");
|
||||
doReturn(parentMasterClassification).when(classificationMapperMock).findByKeyAndDomain("ParentKey", "");
|
||||
|
||||
doReturn(parentRootClassification).when(classificationMapperMock).findById("parentId");
|
||||
doReturn(parentDomainClassification).when(classificationMapperMock).findById("parentId");
|
||||
doReturn(true).when(taskanaEngineImplMock).domainExists(any());
|
||||
|
||||
cutSpy.createClassification(classification);
|
||||
|
||||
verify(classificationMapperMock, times(1)).findByKeyAndDomain("ParentKey", "");
|
||||
verify(classificationMapperMock, times(2)).insert(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -81,7 +81,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
Classification actualClassification;
|
||||
Classification actualClassification2;
|
||||
|
||||
// empty classification (root)
|
||||
// empty classification (master)
|
||||
expectedClassification = (ClassificationImpl) this.createDummyClassificationWithUniqueKey("", "TASK");
|
||||
expectedClassification = (ClassificationImpl) classificationService
|
||||
.createClassification(expectedClassification);
|
||||
|
@ -92,7 +92,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
assertThat(actualClassification.getId(), not(equalTo(null)));
|
||||
assertThat(actualClassification.getId(), startsWith(ID_PREFIX_CLASSIFICATION));
|
||||
|
||||
// specific to domain + root
|
||||
// specific to domain + master
|
||||
expectedClassification = (ClassificationImpl) this.createDummyClassificationWithUniqueKey(domain, "TASK");
|
||||
expectedClassification.setKey(key);
|
||||
expectedClassification = (ClassificationImpl) classificationService
|
||||
|
@ -123,7 +123,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
} catch (ClassificationAlreadyExistException e) {
|
||||
}
|
||||
|
||||
// new classification but root existing
|
||||
// new classification but master existing
|
||||
expectedClassification = (ClassificationImpl) this.createDummyClassificationWithUniqueKey("DOMAIN_B",
|
||||
"TASK");
|
||||
expectedClassification.setKey(key);
|
||||
|
@ -136,8 +136,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
assertThat(actualClassification.getDomain(), equalTo("DOMAIN_B"));
|
||||
assertThat(actualClassification.getId(), startsWith(ID_PREFIX_CLASSIFICATION));
|
||||
// verify that
|
||||
Classification rootResults = classificationService.getClassification(key, "");
|
||||
assertThat(rootResults, not(equalTo(null)));
|
||||
Classification masterResults = classificationService.getClassification(key, "");
|
||||
assertThat(masterResults, not(equalTo(null)));
|
||||
|
||||
// invalid serviceLevel
|
||||
try {
|
||||
|
|
|
@ -89,7 +89,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
Classification actualClassification;
|
||||
Classification actualClassification2;
|
||||
|
||||
// empty classification (root)
|
||||
// empty classification (master)
|
||||
expectedClassification = (ClassificationImpl) this.createNewClassificationWithUniqueKey("", "TASK");
|
||||
expectedClassification = (ClassificationImpl) classificationService
|
||||
.createClassification(expectedClassification);
|
||||
|
@ -101,7 +101,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
assertThat(actualClassification.getId(), not(equalTo(null)));
|
||||
assertThat(actualClassification.getId(), startsWith(ID_PREFIX_CLASSIFICATION));
|
||||
|
||||
// specific to domain + root
|
||||
// specific to domain + master
|
||||
expectedClassification = (ClassificationImpl) this.createNewClassificationWithUniqueKey(domain, "TASK");
|
||||
expectedClassification.setKey(key);
|
||||
expectedClassification = (ClassificationImpl) classificationService
|
||||
|
@ -134,7 +134,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
} catch (ClassificationAlreadyExistException e) {
|
||||
}
|
||||
|
||||
// new classification but root existing
|
||||
// new classification but master existing
|
||||
expectedClassification = (ClassificationImpl) this.createNewClassificationWithUniqueKey("", "TASK");
|
||||
expectedClassification.setKey(key);
|
||||
expectedClassification.setDomain("DOMAIN_B");
|
||||
|
@ -147,8 +147,8 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
assertThat(actualClassification.getKey(), equalTo(key));
|
||||
assertThat(actualClassification.getDomain(), equalTo("DOMAIN_B"));
|
||||
assertThat(actualClassification.getId(), startsWith(ID_PREFIX_CLASSIFICATION));
|
||||
Classification rootResult = classificationService.getClassification(key, "");
|
||||
assertThat(rootResult, not(equalTo(null)));
|
||||
Classification masterResult = classificationService.getClassification(key, "");
|
||||
assertThat(masterResult, not(equalTo(null)));
|
||||
|
||||
// invalid serviceLevel
|
||||
try {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- ID, KEY, PARENT_ID, PARENT_KEY, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, MODIFIED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, APPLICATION_ENTRY_POINT, CUSTOM_1 - 8
|
||||
-- ROOT CLASSIFICATIONS
|
||||
-- MASTER CLASSIFICATIONS
|
||||
INSERT INTO TASKANA.CLASSIFICATION VALUES('CLI:000000000000000000000000000000000001', 'L10000', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'OLD-Leistungsfall', 'OLD-Leistungsfall', 999, 'PT5H', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '');
|
||||
INSERT INTO TASKANA.CLASSIFICATION VALUES('CLI:000000000000000000000000000000000002', 'L10303', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Beratungsprotokoll', 'Beratungsprotokoll', 1, 'P2D', '', 'VNR,RVNR,KOLVNR, ANR', '', '', '', '', '', '', '');
|
||||
INSERT INTO TASKANA.CLASSIFICATION VALUES('CLI:000000000000000000000000000000000003', 'L1050', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Widerruf', 'Widerruf', 1, 'P3D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '');
|
||||
|
|
|
@ -138,6 +138,5 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -74,7 +74,7 @@ describe('ClassificationDetailsComponent', () => {
|
|||
spyOn(classificationCategoriesService, 'getCategoryIcon').and.returnValue(new Pair('assets/icons/categories/external.svg'));
|
||||
component.classification = new ClassificationDefinition('id1', undefined, undefined, undefined, undefined, undefined, undefined,
|
||||
undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined,
|
||||
undefined, undefined, undefined, new LinksClassification({ 'self': '' }));
|
||||
undefined, undefined, undefined, undefined, new LinksClassification({ 'self': '' }));
|
||||
treeService = TestBed.get(TreeService);
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
|
|
|
@ -4,7 +4,6 @@ import { Subscription } from 'rxjs/Subscription';
|
|||
|
||||
import { ClassificationDefinition } from 'app/models/classification-definition';
|
||||
import { ACTION } from 'app/models/action';
|
||||
import { Classification } from 'app/models/classification';
|
||||
import { ErrorModel } from 'app/models/modal-error';
|
||||
import { AlertModel, AlertType } from 'app/models/alert';
|
||||
|
||||
|
@ -35,7 +34,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
|
||||
classification: ClassificationDefinition;
|
||||
classificationClone: ClassificationDefinition;
|
||||
selectedId: string = undefined;
|
||||
selectedClassification: ClassificationDefinition = undefined;
|
||||
showDetail = false;
|
||||
classificationTypes: Array<string> = [];
|
||||
badgeMessage = '';
|
||||
|
@ -59,6 +58,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
private classificationSavingSubscription: Subscription;
|
||||
private classificationRemoveSubscription: Subscription;
|
||||
private selectedClassificationSubscription: Subscription;
|
||||
private selectedClassificationTypeSubscription: Subscription;
|
||||
private categoriesSubscription: Subscription;
|
||||
private domainSubscription: Subscription;
|
||||
|
||||
|
@ -81,10 +81,10 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
this.classificationTypes = classificationTypes;
|
||||
})
|
||||
this.classificationSelectedSubscription = this.classificationsService.getSelectedClassification()
|
||||
.subscribe(classificationIdSelected => {
|
||||
.subscribe(classificationSelected => {
|
||||
this.classification = undefined;
|
||||
if (classificationIdSelected) {
|
||||
this.fillClassificationInformation(classificationIdSelected);
|
||||
if (classificationSelected) {
|
||||
this.fillClassificationInformation(classificationSelected);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -98,7 +98,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
if (id === 'undefined') {
|
||||
id = undefined;
|
||||
}
|
||||
this.fillClassificationInformation(id);
|
||||
this.fillClassificationInformation(new ClassificationDefinition())
|
||||
}
|
||||
|
||||
if (id && id !== '') {
|
||||
|
@ -139,7 +139,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
this.classificationSavingSubscription = this.classificationsService.postClassification(this.classification)
|
||||
.subscribe((classification: ClassificationDefinition) => {
|
||||
this.classification = classification;
|
||||
this.classificationsService.selectClassification(classification.classificationId);
|
||||
this.classificationsService.selectClassification(classification);
|
||||
this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, `Classification ${classification.key} was saved successfully`));
|
||||
this.afterRequest();
|
||||
},
|
||||
|
@ -181,22 +181,21 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
private selectClassification(id: string) {
|
||||
this.selectedId = id;
|
||||
this.classificationsService.selectClassification(id);
|
||||
this.selectedClassificationSubscription = this.classificationsService.getClassification(id).subscribe(classification => {
|
||||
this.selectedClassification = classification;
|
||||
this.classificationsService.selectClassification(classification)
|
||||
});
|
||||
}
|
||||
|
||||
private fillClassificationInformation(classificationIdSelected: string) {
|
||||
private fillClassificationInformation(classificationSelected: ClassificationDefinition) {
|
||||
if (this.action === ACTION.CREATE) { // CREATE
|
||||
this.initClassificationCreation(classificationIdSelected);
|
||||
this.initClassificationCreation(classificationSelected);
|
||||
} else {
|
||||
this.requestInProgress = true;
|
||||
this.classificationServiceSubscription = this.classificationsService.getClassification(classificationIdSelected)
|
||||
.subscribe((classification: ClassificationDefinition) => {
|
||||
this.classification = classification;
|
||||
this.classificationClone = { ...this.classification };
|
||||
this.requestInProgress = false;
|
||||
this.checkDomainAndRedirect();
|
||||
});
|
||||
this.classification = classificationSelected;
|
||||
this.classificationClone = { ...classificationSelected };
|
||||
this.requestInProgress = false;
|
||||
this.checkDomainAndRedirect();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,15 +205,16 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
this.classification.modified = date;
|
||||
}
|
||||
|
||||
private initClassificationCreation(classificationIdSelected: string) {
|
||||
private initClassificationCreation(classificationSelected: ClassificationDefinition) {
|
||||
this.classification = new ClassificationDefinition();
|
||||
this.selectedClassificationSubscription = this.classificationTypeService.getSelectedClassificationType().subscribe(value => {
|
||||
if (this.classification) { this.classification.type = value; }
|
||||
});
|
||||
this.classification.parentId = classificationSelected.classificationId;
|
||||
this.classification.parentKey = classificationSelected.key;
|
||||
this.classification.category = classificationSelected.category;
|
||||
this.classification.domain = this.domainService.getSelectedDomainValue();
|
||||
this.classification.category = this.categories[0];
|
||||
this.selectedClassificationSubscription = this.classificationTypeService.getSelectedClassificationType().subscribe(type => {
|
||||
if (this.classification) { this.classification.type = type; }
|
||||
});
|
||||
this.addDateToClassification();
|
||||
this.classification.parentId = classificationIdSelected;
|
||||
this.classificationClone = { ...this.classification };
|
||||
}
|
||||
|
||||
|
@ -260,6 +260,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
if (this.classificationSavingSubscription) { this.classificationSavingSubscription.unsubscribe(); }
|
||||
if (this.classificationRemoveSubscription) { this.classificationRemoveSubscription.unsubscribe(); }
|
||||
if (this.selectedClassificationSubscription) { this.selectedClassificationSubscription.unsubscribe(); }
|
||||
if (this.selectedClassificationTypeSubscription) { this.selectedClassificationTypeSubscription.unsubscribe(); }
|
||||
if (this.categoriesSubscription) { this.categoriesSubscription.unsubscribe(); }
|
||||
if (this.domainSubscription) { this.domainSubscription.unsubscribe(); }
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
ClassificationCategoriesService
|
||||
} from 'app/administration/services/classification-categories-service/classification-categories.service';
|
||||
import { Pair } from 'app/models/pair';
|
||||
import { ClassificationDefinition } from '../../../../models/classification-definition';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-classification-list',
|
||||
|
@ -101,6 +102,10 @@ export class ClassificationListComponent implements OnInit, OnDestroy {
|
|||
|
||||
this.requestInProgress = true;
|
||||
this.classifications = [];
|
||||
|
||||
if (this.classificationServiceSubscription) { this.classificationServiceSubscription.unsubscribe() }
|
||||
if (this.classificationSelectedSubscription) { this.classificationSelectedSubscription.unsubscribe() }
|
||||
|
||||
this.classificationServiceSubscription = this.classificationService.getClassifications()
|
||||
.subscribe((classifications: Array<TreeNodeModel>) => {
|
||||
this.requestInProgress = false;
|
||||
|
@ -111,8 +116,8 @@ export class ClassificationListComponent implements OnInit, OnDestroy {
|
|||
});
|
||||
});
|
||||
this.classificationSelectedSubscription = this.classificationService.getSelectedClassification()
|
||||
.subscribe((classificationSelected: string) => {
|
||||
setTimeout(() => { this.selectedId = classificationSelected; }, 0);
|
||||
.subscribe((classificationSelected: ClassificationDefinition) => {
|
||||
this.selectedId = classificationSelected ? classificationSelected.classificationId : undefined;
|
||||
});
|
||||
|
||||
this.initialized = true;
|
||||
|
|
|
@ -18,7 +18,7 @@ import { Direction } from 'app/models/sorting';
|
|||
@Injectable()
|
||||
export class ClassificationsService {
|
||||
|
||||
private classificationSelected = new Subject<string>();
|
||||
private classificationSelected = new Subject<ClassificationDefinition>();
|
||||
private classificationSaved = new Subject<number>();
|
||||
|
||||
constructor(
|
||||
|
@ -39,9 +39,8 @@ export class ClassificationsService {
|
|||
key: string = undefined,
|
||||
keyLike: string = undefined,
|
||||
requiredPermission: string = undefined,
|
||||
allPages: boolean = true): Observable<any> {
|
||||
allPages: boolean = true): Observable<Array<Classification>> {
|
||||
return this.domainService.getSelectedDomain().mergeMap(domain => {
|
||||
this.classificationTypeService.getSelectedClassificationType();
|
||||
return this.getClassificationObservable(this.httpClient.get<ClassificationResource>(
|
||||
`${environment.taskanaRestUrl}/v1/classifications/${TaskanaQueryParameters.getQueryParameters(
|
||||
sortBy, order, name,
|
||||
|
@ -81,11 +80,11 @@ export class ClassificationsService {
|
|||
}
|
||||
|
||||
// #region "Service extras"
|
||||
selectClassification(id: string) {
|
||||
this.classificationSelected.next(id);
|
||||
selectClassification(classification: ClassificationDefinition) {
|
||||
this.classificationSelected.next(classification);
|
||||
}
|
||||
|
||||
getSelectedClassification(): Observable<string> {
|
||||
getSelectedClassification(): Observable<ClassificationDefinition> {
|
||||
return this.classificationSelected.asObservable();
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ export class NavBarComponent implements OnInit, OnDestroy {
|
|||
workplaceAccess = false;
|
||||
|
||||
selectedRouteSubscription: Subscription;
|
||||
getDomainsSubscription: Subscription;
|
||||
|
||||
constructor(
|
||||
private selectedRouteService: SelectedRouteService,
|
||||
|
@ -62,7 +63,7 @@ export class NavBarComponent implements OnInit, OnDestroy {
|
|||
this.selectedRoute = value;
|
||||
this.setTitle(value);
|
||||
});
|
||||
this.domainService.getDomains().subscribe(domains => {
|
||||
this.getDomainsSubscription = this.domainService.getDomains().subscribe(domains => {
|
||||
this.domains = domains;
|
||||
});
|
||||
|
||||
|
@ -90,8 +91,8 @@ export class NavBarComponent implements OnInit, OnDestroy {
|
|||
|
||||
showDomainSelector(): boolean {
|
||||
return this.selectedRoute.indexOf('administration') !== -1
|
||||
|| this.selectedRoute.indexOf('workbaskets') !== -1
|
||||
|| this.selectedRoute.indexOf('classifications') !== -1
|
||||
|| this.selectedRoute.indexOf('workbaskets') !== -1
|
||||
|| this.selectedRoute.indexOf('classifications') !== -1
|
||||
}
|
||||
|
||||
private setTitle(value: string = 'workbaskets') {
|
||||
|
@ -108,5 +109,6 @@ export class NavBarComponent implements OnInit, OnDestroy {
|
|||
|
||||
ngOnDestroy(): void {
|
||||
if (this.selectedRouteSubscription) { this.selectedRouteSubscription.unsubscribe(); }
|
||||
if (this.getDomainsSubscription) { this.getDomainsSubscription.unsubscribe(); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ export class ClassificationDefinition {
|
|||
constructor(public classificationId: string = undefined,
|
||||
public key: string = undefined,
|
||||
public parentId: string = undefined,
|
||||
public parentKey: string = undefined,
|
||||
public category: string = undefined,
|
||||
public domain: string = undefined,
|
||||
public type: string = undefined,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { Router } from '@angular/router';
|
||||
|
@ -16,7 +16,7 @@ export class DomainService {
|
|||
private domainRestValue: Array<string> = new Array<string>();
|
||||
private domainValue: Array<string> = new Array<string>();
|
||||
private domainSelectedValue;
|
||||
private domainSelected = new BehaviorSubject<string>('');
|
||||
private domainSelected = new ReplaySubject<string>(1);
|
||||
private dataObs$ = new ReplaySubject<Array<string>>(1);
|
||||
private hasMasterDomain = false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue