Skip to content

Commit 3fce38c

Browse files
committed
Support using g/s factor through UI when doing local anonymizations
1 parent a93eeff commit 3fce38c

File tree

5 files changed

+58
-7
lines changed

5 files changed

+58
-7
lines changed

src/gui/org/deidentifier/arx/gui/Controller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ public void actionMenuEditAnonymize() {
604604
}
605605

606606
// Open configuration dialog
607-
ModelAnonymizationConfiguration configuration = this.actionShowLocalAnonymizationDialog();
607+
ModelAnonymizationConfiguration configuration = this.actionShowAnonymizationDialog();
608608
if (configuration == null) {
609609
return;
610610
}
@@ -1817,11 +1817,11 @@ public String actionShowInputDialog(final Shell shell,
18171817
}
18181818

18191819
/**
1820-
* Shows a dialog for configuration of local anonymization.
1820+
* Shows a dialog for configuration of anonymization.
18211821
* @return Returns the parameters selected by the user. Returns a pair.
18221822
* First: max. time per iteration. Second: min. records per iteration.
18231823
*/
1824-
public ModelAnonymizationConfiguration actionShowLocalAnonymizationDialog() {
1824+
public ModelAnonymizationConfiguration actionShowAnonymizationDialog() {
18251825
return main.showLocalAnonymizationDialog(model);
18261826
}
18271827

src/gui/org/deidentifier/arx/gui/model/ModelAnonymizationConfiguration.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public static enum TransformationType {
6060
private ModelAnonymizationConfiguration.TransformationType transformationType = TransformationType.GLOBAL;
6161
/** Limits */
6262
private Boolean stepLimitEnabled = false;
63+
/** Code model settings*/
64+
private Boolean useCodingModelSettings = false;
6365

6466
/**
6567
* Creates a new instance
@@ -143,6 +145,18 @@ public boolean isTimeLimitEnabled() {
143145
return !isStepLimitEnabled();
144146
}
145147

148+
/**
149+
* Use coding model settings from main UI
150+
* @return
151+
*/
152+
public boolean isUseCodingModelSettings() {
153+
// Backwards compatibility
154+
if (this.useCodingModelSettings == null) {
155+
this.useCodingModelSettings = false;
156+
}
157+
return this.useCodingModelSettings;
158+
}
159+
146160
/**
147161
* @param heuristicSearchStepLimit the heuristicSearchStepLimit to set
148162
*/
@@ -156,7 +170,7 @@ public void setHeuristicSearchStepLimit(int heuristicSearchStepLimit) {
156170
public void setHeuristicSearchTimeLimit(double heuristicSearchTimeLimit) {
157171
model.setHeuristicSearchTimeLimit((int)(heuristicSearchTimeLimit * 1000d));
158172
}
159-
173+
160174
/**
161175
* @param numIterations the numIterations to set
162176
*/
@@ -191,4 +205,12 @@ public void setTimeLimitEnabled(boolean timeLimitEnabled) {
191205
public void setTransformationType(ModelAnonymizationConfiguration.TransformationType transformationType) {
192206
this.transformationType = transformationType;
193207
}
208+
209+
/**
210+
* Set use coding model
211+
* @param useCodingModelSettings
212+
*/
213+
public void setUseCodingModelSettings(boolean useCodingModelSettings) {
214+
this.useCodingModelSettings = useCodingModelSettings;
215+
}
194216
}

src/gui/org/deidentifier/arx/gui/resources/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,7 @@ DialogAnonymization.19=Best-effort, binary
14941494
DialogAnonymization.20=Best-effort, top down
14951495
DialogAnonymization.21=No algorithm has been selected
14961496
DialogAnonymization.22=No transformation type has been selected
1497+
DialogAnonymization.23=Use coding model settings
14971498
PaginationTable.0=Previous
14981499
PaginationTable.1=Next
14991500
PaginationTable.2=Items {0}-{1} of {2}

src/gui/org/deidentifier/arx/gui/view/impl/menu/DialogAnonymization.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public class DialogAnonymization extends TitleAreaDialog {
7575
private Text txtHeuristicSearchStepLimit;
7676
/** View */
7777
private Text textNumIterations;
78+
/** Button */
79+
private Button btnUseCodingModelSettings;
7880
/** View */
7981
private Button radioTimeLimit;
8082
/** View */
@@ -185,6 +187,10 @@ private void checkAndUpdateModel() {
185187
configuration.setNumIterations(getNumIterations());
186188
}
187189

190+
// Handle parameter
191+
configuration.setUseCodingModelSettings(this.btnUseCodingModelSettings.getSelection());
192+
193+
// Handle parameters
188194
if (btnLocalTransformation.isEnabled() && btnLocalTransformation.getSelection()) {
189195
configuration.setTransformationType(TransformationType.LOCAL);
190196
} else if (btnGlobalTransformation.isEnabled() && btnGlobalTransformation.getSelection()) {
@@ -380,12 +386,12 @@ protected Control createDialogArea(Composite parent) {
380386
GridData data3 = SWTUtil.createFillGridData();
381387
data3.horizontalIndent = 5;
382388
group3.setLayoutData(data3);
383-
group3.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).create());
389+
group3.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());
384390

385391
// Radio - global transformation
386392
this.btnGlobalTransformation = new Button(group3, SWT.RADIO);
387393
this.btnGlobalTransformation.setText(Resources.getMessage("DialogAnonymization.10")); //$NON-NLS-1$
388-
this.btnGlobalTransformation.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());
394+
this.btnGlobalTransformation.setLayoutData(GridDataFactory.swtDefaults().span(3, 1).create());
389395

390396
// Radio - local transformation
391397
this.btnLocalTransformation = new Button(group3, SWT.RADIO);
@@ -394,6 +400,10 @@ protected Control createDialogArea(Composite parent) {
394400
// Tet - number iterations
395401
this.textNumIterations = new Text(group3, SWT.BORDER);
396402
this.textNumIterations.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
403+
404+
this.btnUseCodingModelSettings = new Button(group3, SWT.CHECK);
405+
this.btnUseCodingModelSettings.setText(Resources.getMessage("DialogAnonymization.23")); //$NON-NLS-1$
406+
this.btnUseCodingModelSettings.setLayoutData(GridDataFactory.swtDefaults().create());
397407

398408
/*
399409
* Set initial values
@@ -425,6 +435,7 @@ protected Control createDialogArea(Composite parent) {
425435
case LOCAL: btnLocalTransformation.setSelection(true); break;
426436
}
427437
this.textNumIterations.setText(String.valueOf(configuration.getNumIterations()));
438+
this.btnUseCodingModelSettings.setSelection(configuration.isUseCodingModelSettings());
428439

429440
/*
430441
* Customize according to currently available settings
@@ -438,6 +449,7 @@ protected Control createDialogArea(Composite parent) {
438449
this.btnGlobalTransformation.setSelection(true);
439450
this.configuration.setTransformationType(TransformationType.GLOBAL);
440451
this.textNumIterations.setEnabled(false);
452+
this.btnUseCodingModelSettings.setEnabled(false);
441453
createMessage(group3, 2, Resources.getMessage("DialogAnonymization.12")); //$NON-NLS-1$
442454
}
443455

@@ -601,6 +613,15 @@ public void modifyText(ModifyEvent arg0) {
601613
}
602614
});
603615

616+
this.btnUseCodingModelSettings.addSelectionListener(new SelectionAdapter() {
617+
@Override
618+
public void widgetSelected(SelectionEvent arg0) {
619+
btnLocalTransformation.setSelection(true);
620+
btnGlobalTransformation.setSelection(false);
621+
checkAndUpdateModel();
622+
}
623+
});
624+
604625
// Done
605626
applyDialogFont(base);
606627
checkAndUpdateModel();

src/gui/org/deidentifier/arx/gui/worker/WorkerAnonymize.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,14 @@ public void run(final IProgressMonitor monitor) throws InvocationTargetException
111111
// Overwrite user-defined settings to prepare local recoding
112112
if (transformationType == TransformationType.LOCAL) {
113113
MetricConfiguration metricConfig = config.getQualityModel().getConfiguration();
114-
metricConfig.setGsFactor(0d);
114+
115+
// Use user-defined gs factor, if configured
116+
if (model.getAnonymizationConfiguration().isUseCodingModelSettings()) {
117+
metricConfig.setGsFactor(model.getMetricConfiguration().getGsFactor());
118+
// Default is 0
119+
} else {
120+
metricConfig.setGsFactor(0d);
121+
}
115122
config.setQualityModel(config.getQualityModel().getDescription().createInstance(metricConfig));
116123
config.setSuppressionLimit(1d - (1d / (double)model.getLocalRecodingModel().getNumIterations()));
117124
}

0 commit comments

Comments
 (0)